Trait musli_utils::Writer
source · pub trait Writer {
type Mut<'this>: Writer
where Self: 'this;
// Required methods
fn borrow_mut(&mut self) -> Self::Mut<'_>;
fn write_buffer<C, B>(&mut self, cx: &C, buffer: B) -> Result<(), C::Error>
where C: ?Sized + Context,
B: Buf;
fn write_bytes<C>(&mut self, cx: &C, bytes: &[u8]) -> Result<(), C::Error>
where C: ?Sized + Context;
// Provided method
fn write_byte<C>(&mut self, cx: &C, b: u8) -> Result<(), C::Error>
where C: ?Sized + Context { ... }
}
Expand description
The trait governing how a writer works.
Required Associated Types§
sourcetype Mut<'this>: Writer
where
Self: 'this
type Mut<'this>: Writer where Self: 'this
Reborrowed type.
Why oh why would we want to do this over having a simple &'this mut T
?
We want to avoid recursive types, which will blow up the compiler. And
the above is a typical example of when that can go wrong. This ensures
that each call to borrow_mut
dereferences the Reader
at each step to
avoid constructing a large muted type, like &mut &mut &mut VecWriter
.
Required Methods§
sourcefn borrow_mut(&mut self) -> Self::Mut<'_>
fn borrow_mut(&mut self) -> Self::Mut<'_>
Reborrow the current type.
Provided Methods§
Object Safety§
This trait is not object safe.