pub trait Parse<'a, T>: Sealed {
// Required method
fn from_buffered_reader<R>(reader: R) -> Result<T>
where R: BufferedReader<Cookie> + 'a;
// Provided methods
fn from_reader<R: 'a + Read + Send + Sync>(reader: R) -> Result<T> { ... }
fn from_file<P: AsRef<Path>>(path: P) -> Result<T> { ... }
fn from_bytes<D: AsRef<[u8]> + ?Sized + Send + Sync>(
data: &'a D,
) -> Result<T> { ... }
}
Expand description
Parsing of packets and related structures.
This is a uniform interface to parse packets, messages, keys, and related data structures.
§Sealed trait
This trait is sealed and cannot be implemented for types outside this crate.
Therefore it can be extended in a non-breaking way.
If you want to implement the trait inside the crate
you also need to implement the seal::Sealed
marker trait.
Required Methods§
Sourcefn from_buffered_reader<R>(reader: R) -> Result<T>where
R: BufferedReader<Cookie> + 'a,
fn from_buffered_reader<R>(reader: R) -> Result<T>where
R: BufferedReader<Cookie> + 'a,
Reads from the given buffered reader.
Implementations of this function should be short. Ideally,
they should hand of the reader to a private function erasing
the readers type by invoking BufferedReader::into_boxed
.
Provided Methods§
Sourcefn from_reader<R: 'a + Read + Send + Sync>(reader: R) -> Result<T>
fn from_reader<R: 'a + Read + Send + Sync>(reader: R) -> Result<T>
Reads from the given reader.
The default implementation just uses
Parse::from_buffered_reader
, but implementations can
provide their own specialized version.
Sourcefn from_file<P: AsRef<Path>>(path: P) -> Result<T>
fn from_file<P: AsRef<Path>>(path: P) -> Result<T>
Reads from the given file.
The default implementation just uses
Parse::from_buffered_reader
, but implementations can
provide their own specialized version.
Sourcefn from_bytes<D: AsRef<[u8]> + ?Sized + Send + Sync>(data: &'a D) -> Result<T>
fn from_bytes<D: AsRef<[u8]> + ?Sized + Send + Sync>(data: &'a D) -> Result<T>
Reads from the given slice.
The default implementation just uses
Parse::from_buffered_reader
, but implementations can
provide their own specialized version.
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.