Trait netstack3_base::ContextProvider

source ·
pub trait ContextProvider {
    type Context: Sized;

    // Required method
    fn context(&mut self) -> &mut Self::Context;
}
Expand description

A type that provides a context implementation.

This trait allows for CtxPair to hold context implementations agnostically of the storage method and how they’re implemented. For example, tests usually create API structs with a mutable borrow to contexts, while the core context exposed to bindings is implemented on an owned [CoreCtx] type.

The shape of this trait is equivalent to core::ops::DerefMut but we decide against using that because of the automatic dereferencing semantics the compiler provides around implementers of DerefMut.

Required Associated Types§

source

type Context: Sized

The context provided by this ContextProvider.

Required Methods§

source

fn context(&mut self) -> &mut Self::Context

Gets a mutable borrow to this context.

Implementations on Foreign Types§

source§

impl<'a, T: Sized> ContextProvider for &'a mut T

§

type Context = T

source§

fn context(&mut self) -> &mut Self::Context

Implementors§