pub trait WriteContext {
// Required methods
fn write_bytes(&mut self, data: &[u8]) -> Result<(), WriteError>;
fn write_zeros(&mut self, count: usize) -> Result<(), WriteError>;
fn bytes_written(&self) -> usize;
fn write_placeholder<T, HostType>(
&mut self,
placeholder: Placeholder<T, HostType>,
val: HostType,
) -> Result<T::Output, WriteError>
where T: WriteBinary<HostType>;
fn write_placeholder_dep<T, HostType>(
&mut self,
placeholder: Placeholder<T, HostType>,
val: HostType,
args: T::Args,
) -> Result<T::Output, WriteError>
where T: WriteBinaryDep<HostType>;
// Provided methods
fn write_array<'a, T>(
&mut self,
array: &ReadArray<'a, T>,
) -> Result<(), WriteError>
where Self: Sized,
T: ReadUnchecked + WriteBinary<<T as ReadUnchecked>::HostType> { ... }
fn write_vec<T, HostType>(
&mut self,
vec: Vec<HostType>,
) -> Result<(), WriteError>
where Self: Sized,
T: WriteBinary<HostType> { ... }
fn write_iter<T, HostType>(
&mut self,
iter: impl Iterator<Item = HostType>,
) -> Result<(), WriteError>
where Self: Sized,
T: WriteBinary<HostType> { ... }
fn placeholder<'a, T, HostType>(
&mut self,
) -> Result<Placeholder<T, HostType>, WriteError>
where T: WriteBinary<HostType> + ReadUnchecked { ... }
fn reserve<'a, T, HostType>(
&mut self,
count: usize,
) -> Result<Placeholder<T, &'a HostType>, WriteError>
where T: WriteBinaryDep<&'a HostType> { ... }
fn placeholder_array<'a, T, HostType>(
&mut self,
count: usize,
) -> Result<Vec<Placeholder<T, HostType>>, WriteError>
where T: WriteBinary<HostType> + ReadUnchecked { ... }
}Expand description
Trait for types that can have binary data written to them.
Required Methods§
Sourcefn write_bytes(&mut self, data: &[u8]) -> Result<(), WriteError>
fn write_bytes(&mut self, data: &[u8]) -> Result<(), WriteError>
Write a slice of bytes to a WriteContext.
Sourcefn write_zeros(&mut self, count: usize) -> Result<(), WriteError>
fn write_zeros(&mut self, count: usize) -> Result<(), WriteError>
Write the specified number of zero bytes to the WriteContext.
Sourcefn bytes_written(&self) -> usize
fn bytes_written(&self) -> usize
The total number of bytes written so far.
Sourcefn write_placeholder<T, HostType>(
&mut self,
placeholder: Placeholder<T, HostType>,
val: HostType,
) -> Result<T::Output, WriteError>where
T: WriteBinary<HostType>,
fn write_placeholder<T, HostType>(
&mut self,
placeholder: Placeholder<T, HostType>,
val: HostType,
) -> Result<T::Output, WriteError>where
T: WriteBinary<HostType>,
Consumes the placeholder and writes the supplied value into it
Sourcefn write_placeholder_dep<T, HostType>(
&mut self,
placeholder: Placeholder<T, HostType>,
val: HostType,
args: T::Args,
) -> Result<T::Output, WriteError>where
T: WriteBinaryDep<HostType>,
fn write_placeholder_dep<T, HostType>(
&mut self,
placeholder: Placeholder<T, HostType>,
val: HostType,
args: T::Args,
) -> Result<T::Output, WriteError>where
T: WriteBinaryDep<HostType>,
Consumes the placeholder and writes the supplied value into it.
WriteBinaryDep version
Provided Methods§
Sourcefn write_array<'a, T>(
&mut self,
array: &ReadArray<'a, T>,
) -> Result<(), WriteError>
fn write_array<'a, T>( &mut self, array: &ReadArray<'a, T>, ) -> Result<(), WriteError>
Write a ReadArray instance to a WriteContext.
Sourcefn write_vec<T, HostType>(
&mut self,
vec: Vec<HostType>,
) -> Result<(), WriteError>where
Self: Sized,
T: WriteBinary<HostType>,
fn write_vec<T, HostType>(
&mut self,
vec: Vec<HostType>,
) -> Result<(), WriteError>where
Self: Sized,
T: WriteBinary<HostType>,
Write a Vec into a WriteContext.
Sourcefn write_iter<T, HostType>(
&mut self,
iter: impl Iterator<Item = HostType>,
) -> Result<(), WriteError>where
Self: Sized,
T: WriteBinary<HostType>,
fn write_iter<T, HostType>(
&mut self,
iter: impl Iterator<Item = HostType>,
) -> Result<(), WriteError>where
Self: Sized,
T: WriteBinary<HostType>,
Write a slice of values into a WriteContext.
Sourcefn placeholder<'a, T, HostType>(
&mut self,
) -> Result<Placeholder<T, HostType>, WriteError>where
T: WriteBinary<HostType> + ReadUnchecked,
fn placeholder<'a, T, HostType>(
&mut self,
) -> Result<Placeholder<T, HostType>, WriteError>where
T: WriteBinary<HostType> + ReadUnchecked,
Return a placeholder to T in the context for filling in later.
Sourcefn reserve<'a, T, HostType>(
&mut self,
count: usize,
) -> Result<Placeholder<T, &'a HostType>, WriteError>where
T: WriteBinaryDep<&'a HostType>,
fn reserve<'a, T, HostType>(
&mut self,
count: usize,
) -> Result<Placeholder<T, &'a HostType>, WriteError>where
T: WriteBinaryDep<&'a HostType>,
Reserve space for count bytes in the context for filling in later.
Sourcefn placeholder_array<'a, T, HostType>(
&mut self,
count: usize,
) -> Result<Vec<Placeholder<T, HostType>>, WriteError>where
T: WriteBinary<HostType> + ReadUnchecked,
fn placeholder_array<'a, T, HostType>(
&mut self,
count: usize,
) -> Result<Vec<Placeholder<T, HostType>>, WriteError>where
T: WriteBinary<HostType> + ReadUnchecked,
Return a Vec of count placeholders of type T.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.