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> 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
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§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.§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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> Source for T
impl<T> Source for T
§type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a>
where
T: 'a
type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a> where T: 'a
A type this
Source
can be sliced into.§fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>where
Chunk: Chunk<'a>,
fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>where
Chunk: Chunk<'a>,
Read a chunk of bytes into an array. Returns
None
when reading
out of bounds would occur. Read more§fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>
fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>
Get a slice of the source at given range. This is analogous to
slice::get(range)
. Read more§fn is_boundary(&self, index: usize) -> bool
fn is_boundary(&self, index: usize) -> bool
§fn find_boundary(&self, index: usize) -> usize
fn find_boundary(&self, index: usize) -> usize
For
&str
sources attempts to find the closest char
boundary at which source
can be sliced, starting from index
. Read more