pub enum MaybeMutable<T> {
Mutable(Arc<T>),
Immutable(Arc<T>),
}Available on crate feature
p3 only.Expand description
An Arc, which may be immutable.
In wasi:http resources like fields or request-options may be
mutable or immutable. This construct is used to model them efficiently.
Variants§
Implementations§
Source§impl<T> MaybeMutable<T>
impl<T> MaybeMutable<T>
Sourcepub fn new_mutable(v: impl Into<Arc<T>>) -> Self
pub fn new_mutable(v: impl Into<Arc<T>>) -> Self
Construct a mutable MaybeMutable.
Sourcepub fn new_mutable_default() -> Selfwhere
T: Default,
pub fn new_mutable_default() -> Selfwhere
T: Default,
Construct a mutable MaybeMutable filling it with default T.
Sourcepub fn new_immutable(v: impl Into<Arc<T>>) -> Self
pub fn new_immutable(v: impl Into<Arc<T>>) -> Self
Construct an immutable MaybeMutable.
Sourcepub fn into_arc(self) -> Arc<T>
pub fn into_arc(self) -> Arc<T>
Unwrap MaybeMutable into Arc.
Sourcepub fn get_mut(&mut self) -> Option<&mut T>where
T: Clone,
pub fn get_mut(&mut self) -> Option<&mut T>where
T: Clone,
If this MaybeMutable is Mutable,
return a mutable reference to it, otherwise return None.
Internally, this will use Arc::make_mut and will clone the underlying
value, if multiple strong references to the inner Arc exist.
Trait Implementations§
Source§impl<T> Deref for MaybeMutable<T>
impl<T> Deref for MaybeMutable<T>
Source§impl<T> From<MaybeMutable<T>> for Arc<T>
impl<T> From<MaybeMutable<T>> for Arc<T>
Source§fn from(v: MaybeMutable<T>) -> Self
fn from(v: MaybeMutable<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> Freeze for MaybeMutable<T>
impl<T> RefUnwindSafe for MaybeMutable<T>where
T: RefUnwindSafe,
impl<T> Send for MaybeMutable<T>
impl<T> Sync for MaybeMutable<T>
impl<T> Unpin for MaybeMutable<T>
impl<T> UnsafeUnpin for MaybeMutable<T>
impl<T> UnwindSafe for MaybeMutable<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self file descriptor. Read more