Trait nix_compat::nix_daemon::de::NixRead
source · pub trait NixRead: Send {
type Error: Error + Send;
// Required methods
fn version(&self) -> ProtocolVersion;
fn try_read_number(
&mut self,
) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + '_;
fn try_read_bytes_limited(
&mut self,
limit: RangeInclusive<usize>,
) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_;
// Provided methods
fn try_read_bytes(
&mut self,
) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_ { ... }
fn read_number(
&mut self,
) -> impl Future<Output = Result<u64, Self::Error>> + Send + '_ { ... }
fn read_bytes_limited(
&mut self,
limit: RangeInclusive<usize>,
) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_ { ... }
fn read_bytes(
&mut self,
) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_ { ... }
fn read_value<V: NixDeserialize>(
&mut self,
) -> impl Future<Output = Result<V, Self::Error>> + Send + '_ { ... }
fn try_read_value<V: NixDeserialize>(
&mut self,
) -> impl Future<Output = Result<Option<V>, Self::Error>> + Send + '_ { ... }
}
Expand description
A reader of data from the Nix daemon protocol. Basically there are two basic types in the Nix daemon protocol u64 and a bytes buffer. Everything else is more or less built on top of these two types.
Required Associated Types§
Required Methods§
sourcefn version(&self) -> ProtocolVersion
fn version(&self) -> ProtocolVersion
Some types are serialized differently depending on the version of the protocol and so this can be used for implementing that.
sourcefn try_read_number(
&mut self,
) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + '_
fn try_read_number( &mut self, ) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + '_
Read a single u64 from the protocol. This returns an Option to support graceful shutdown.
sourcefn try_read_bytes_limited(
&mut self,
limit: RangeInclusive<usize>,
) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_
fn try_read_bytes_limited( &mut self, limit: RangeInclusive<usize>, ) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_
Read bytes from the protocol. A size limit on the returned bytes has to be specified. This returns an Option to support graceful shutdown.
Provided Methods§
sourcefn try_read_bytes(
&mut self,
) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_
fn try_read_bytes( &mut self, ) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_
Read bytes from the protocol without a limit.
The default implementation just calls try_read_bytes_limited
with a
limit of 0..=usize::MAX
but other implementations are free to have a
reader wide limit.
This returns an Option to support graceful shutdown.
sourcefn read_number(
&mut self,
) -> impl Future<Output = Result<u64, Self::Error>> + Send + '_
fn read_number( &mut self, ) -> impl Future<Output = Result<u64, Self::Error>> + Send + '_
Read a single u64 from the protocol. This will return an error if the number could not be read.
sourcefn read_bytes_limited(
&mut self,
limit: RangeInclusive<usize>,
) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_
fn read_bytes_limited( &mut self, limit: RangeInclusive<usize>, ) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_
Read bytes from the protocol. A size limit on the returned bytes has to be specified. This will return an error if the number could not be read.
sourcefn read_bytes(
&mut self,
) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_
fn read_bytes( &mut self, ) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_
Read bytes from the protocol.
The default implementation just calls read_bytes_limited
with a
limit of 0..=usize::MAX
but other implementations are free to have a
reader wide limit.
This will return an error if the bytes could not be read.
sourcefn read_value<V: NixDeserialize>(
&mut self,
) -> impl Future<Output = Result<V, Self::Error>> + Send + '_
fn read_value<V: NixDeserialize>( &mut self, ) -> impl Future<Output = Result<V, Self::Error>> + Send + '_
Read a value from the protocol.
Uses NixDeserialize::deserialize
to read a value.
sourcefn try_read_value<V: NixDeserialize>(
&mut self,
) -> impl Future<Output = Result<Option<V>, Self::Error>> + Send + '_
fn try_read_value<V: NixDeserialize>( &mut self, ) -> impl Future<Output = Result<Option<V>, Self::Error>> + Send + '_
Read a value from the protocol.
Uses NixDeserialize::try_deserialize
to read a value.
This returns an Option to support graceful shutdown.