Enum smoltcp::Managed
[−]
[src]
pub enum Managed<'a, T: 'a + ?Sized> { Borrowed(&'a mut T), Owned(Box<BorrowMut<T>>), }
A managed object.
This enum can be used to represent exclusive access to objects. In Rust, exclusive access to an object is obtained by either owning the object, or owning a mutable pointer to the object; hence, "managed".
The purpose of this enum is providing good ergonomics with std
present while making
it possible to avoid having a heap at all (which of course means that std
is not present).
To achieve this, the Managed::Owned
variant is only available when the "std" feature
is enabled.
A function that requires a managed object should be generic over an Into<Managed<'a, T>>
argument; then, it will be possible to pass either a Box<T>
, Vec<T>
, or a &'a mut T
without any conversion at the call site.
Variants
Borrowed(&'a mut T)
Borrowed variant, either a single element or a slice.
Owned(Box<BorrowMut<T>>)
Owned variant, only available with std
present.
Trait Implementations
impl<'a, T: 'a + Debug + ?Sized> Debug for Managed<'a, T>
[src]
impl<'a, T: 'a + ?Sized> From<&'a mut T> for Managed<'a, T>
[src]
fn from(value: &'a mut T) -> Self
Performs the conversion.
impl<T, U: BorrowMut<T> + 'static> From<Box<U>> for Managed<'static, T>
[src]
impl<T: 'static> From<Vec<T>> for Managed<'static, [T]>
[src]
impl<'a, T: 'a + ?Sized> Deref for Managed<'a, T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
The method called to dereference a value
impl<'a, T: 'a + ?Sized> DerefMut for Managed<'a, T>
[src]
impl<'a> Into<SocketBuffer<'a>> for Managed<'a, [u8]>
[src]
fn into(self) -> SocketBuffer<'a>
Performs the conversion.