pub trait InputCodec<T>: Send + Sync {
// Required methods
fn metadata(&self) -> &'static CodecMetadata;
fn read(&self, reader: &mut dyn Read) -> Result<T, InputCodecError>;
// Provided methods
fn read_path(&self, path: &Path) -> Result<T, InputCodecError> { ... }
fn decode(&self, input: &str) -> Result<T, InputCodecError> { ... }
fn read_bytes(&self, input: &[u8]) -> Result<T, InputCodecError> { ... }
}Expand description
Decode a byte stream into a value of type T.
Required Methods§
Sourcefn metadata(&self) -> &'static CodecMetadata
fn metadata(&self) -> &'static CodecMetadata
Return static codec metadata. This must not read or parse input.
Sourcefn read(&self, reader: &mut dyn Read) -> Result<T, InputCodecError>
fn read(&self, reader: &mut dyn Read) -> Result<T, InputCodecError>
Decode a byte stream.
Provided Methods§
Sourcefn read_path(&self, path: &Path) -> Result<T, InputCodecError>
fn read_path(&self, path: &Path) -> Result<T, InputCodecError>
Decode a file. Codecs with path-relative semantics may override this method.
Sourcefn decode(&self, input: &str) -> Result<T, InputCodecError>
fn decode(&self, input: &str) -> Result<T, InputCodecError>
Decode UTF-8 text.
Sourcefn read_bytes(&self, input: &[u8]) -> Result<T, InputCodecError>
fn read_bytes(&self, input: &[u8]) -> Result<T, InputCodecError>
Decode an in-memory byte sequence.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".