Skip to main content

WriteCollection

Trait WriteCollection 

Source
pub trait WriteCollection<Ctx> {
    // Required methods
    fn write_slice_with<T, E, F>(&mut self, slice: &[T], f: F) -> Result<(), E>
       where E: From<Error>,
             F: FnMut(&mut Writer<Ctx>, &T) -> Result<(), E>;
    fn write_prefixed_slice_with<T, L, E, F>(
        &mut self,
        slice: &[T],
        f: F,
    ) -> Result<(), E>
       where L: Encode<Ctx, Error = Error> + CollectionLength,
             E: From<Error>,
             F: FnMut(&mut Writer<Ctx>, &T) -> Result<(), E>;

    // Provided methods
    fn write_slice<T>(&mut self, slice: &[T]) -> Result<(), T::Error>
       where T: Encode<Ctx> { ... }
    fn write_prefixed_slice<T, L>(
        &mut self,
        slice: &[T],
    ) -> Result<(), T::Error>
       where T: Encode<Ctx>,
             L: Encode<Ctx, Error = Error> + CollectionLength { ... }
}
Expand description

A trait for writing collections of data to a writer.

Required Methods§

Source

fn write_slice_with<T, E, F>(&mut self, slice: &[T], f: F) -> Result<(), E>
where E: From<Error>, F: FnMut(&mut Writer<Ctx>, &T) -> Result<(), E>,

Writes a slice of elements to the writer using the provided function.

Source

fn write_prefixed_slice_with<T, L, E, F>( &mut self, slice: &[T], f: F, ) -> Result<(), E>
where L: Encode<Ctx, Error = Error> + CollectionLength, E: From<Error>, F: FnMut(&mut Writer<Ctx>, &T) -> Result<(), E>,

Writes a slice of elements to the writer with a length prefix, using the provided function to write each element.

Provided Methods§

Source

fn write_slice<T>(&mut self, slice: &[T]) -> Result<(), T::Error>
where T: Encode<Ctx>,

Writes a slice of elements to the writer using the Encode trait.

Source

fn write_prefixed_slice<T, L>(&mut self, slice: &[T]) -> Result<(), T::Error>
where T: Encode<Ctx>, L: Encode<Ctx, Error = Error> + CollectionLength,

Writes a slice of elements to the writer with a length prefix, using the Encode trait to write each element.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<Ctx> WriteCollection<Ctx> for Writer<Ctx>