pub struct GuardedStreamWriter<T, A>where
A: AsAccessor,{ /* private fields */ }
Available on crate features
runtime
and component-model
and component-model-async
only.Expand description
A StreamWriter
paired with an [Accessor
].
This is an RAII wrapper around StreamWriter
that ensures it is closed
when dropped. This can be created through GuardedStreamWriter::new
or
StreamWriter::guard
.
Implementations§
Source§impl<T, A> GuardedStreamWriter<T, A>where
A: AsAccessor,
impl<T, A> GuardedStreamWriter<T, A>where
A: AsAccessor,
Sourcepub fn new(accessor: A, writer: StreamWriter<T>) -> Self
pub fn new(accessor: A, writer: StreamWriter<T>) -> Self
Create a new GuardedStreamWriter
with the specified accessor
and writer
.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Wrapper for StreamWriter::is_closed
.
Sourcepub async fn write<B>(&mut self, buffer: B) -> Bwhere
T: Lower + 'static,
B: WriteBuffer<T>,
pub async fn write<B>(&mut self, buffer: B) -> Bwhere
T: Lower + 'static,
B: WriteBuffer<T>,
Wrapper for StreamWriter::write
.
Sourcepub async fn write_all<B>(&mut self, buffer: B) -> Bwhere
T: Lower + 'static,
B: WriteBuffer<T>,
pub async fn write_all<B>(&mut self, buffer: B) -> Bwhere
T: Lower + 'static,
B: WriteBuffer<T>,
Wrapper for StreamWriter::write_all
.
Sourcepub async fn watch_reader(&mut self)
pub async fn watch_reader(&mut self)
Wrapper for StreamWriter::watch_reader
.
Sourcepub fn into_stream(self) -> StreamWriter<T>
pub fn into_stream(self) -> StreamWriter<T>
Extracts the underlying StreamWriter
from this guard, returning it
back.
Trait Implementations§
Source§impl<T, A> Drop for GuardedStreamWriter<T, A>where
A: AsAccessor,
impl<T, A> Drop for GuardedStreamWriter<T, A>where
A: AsAccessor,
Source§impl<T, A> From<GuardedStreamWriter<T, A>> for StreamWriter<T>where
A: AsAccessor,
impl<T, A> From<GuardedStreamWriter<T, A>> for StreamWriter<T>where
A: AsAccessor,
Source§fn from(guard: GuardedStreamWriter<T, A>) -> Self
fn from(guard: GuardedStreamWriter<T, A>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T, A> Freeze for GuardedStreamWriter<T, A>where
A: Freeze,
impl<T, A> RefUnwindSafe for GuardedStreamWriter<T, A>where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Send for GuardedStreamWriter<T, A>
impl<T, A> Sync for GuardedStreamWriter<T, A>
impl<T, A> Unpin for GuardedStreamWriter<T, A>
impl<T, A> UnwindSafe for GuardedStreamWriter<T, A>where
A: UnwindSafe,
T: UnwindSafe,
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> 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