Skip to main content

Decode

Trait Decode 

Source
pub trait Decode: Sized {
    // Required method
    fn decode(input: &mut impl BufRead) -> Result<Self, DecodeError>;

    // Provided methods
    fn try_decode(input: &mut impl BufRead) -> Result<Option<Self>, DecodeError> { ... }
    fn decode_str(input: &str) -> Result<Self, DecodeError> { ... }
    fn decode_bytes(input: &[u8]) -> Result<Self, DecodeError> { ... }
}
Expand description

Decodes a value from unified diff text.

The default decode_str/decode_bytes adapters route through decode so a single BufRead-based implementation covers all input shapes.

Required Methods§

Source

fn decode(input: &mut impl BufRead) -> Result<Self, DecodeError>

Reads and decodes a value from a buffered input stream.

Provided Methods§

Source

fn try_decode(input: &mut impl BufRead) -> Result<Option<Self>, DecodeError>

Reads and decodes a value, returning Ok(None) at clean end-of-input. Anything else, including a partial value followed by EOF surfaces as Err.

Source

fn decode_str(input: &str) -> Result<Self, DecodeError>

Decodes a value from a UTF-8 string.

Source

fn decode_bytes(input: &[u8]) -> Result<Self, DecodeError>

Decodes a value from raw UTF-8 bytes.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§