Skip to main content

Code

Trait Code 

Source
pub trait Code<T>: Sized {
    type Item;

    // Required methods
    fn code(&mut self, item: T) -> Result<Option<Self::Item>>;
    fn code_eof(&mut self) -> Result<Option<Self::Item>>;

    // Provided methods
    fn is_end_stream(&self, body: &impl Body) -> bool { ... }
    fn size_hint(&self, body: &impl Body) -> SizeHint { ... }
}

Required Associated Types§

Required Methods§

Source

fn code(&mut self, item: T) -> Result<Option<Self::Item>>

Source

fn code_eof(&mut self) -> Result<Option<Self::Item>>

Provided Methods§

Source

fn is_end_stream(&self, body: &impl Body) -> bool

A helper method for overriding associated input body’s end_stream state. by default it returns value the same as Body::is_end_stream’s default value. in other word the default prediction is (de)compress can not hint if body has ended.

Source

fn size_hint(&self, body: &impl Body) -> SizeHint

A helper method for overriding associated input body’s size_hint. by default it returns value the same as SizeHint’s default value. in other word the default prediction is (de)compress can not hint an exact size.

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.

Implementors§

Source§

impl<T> Code<T> for FeaturedCode
where T: AsRef<[u8]> + 'static,