Trait nix_compat::wire::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§

source

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.

source

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.

source

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§

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: ?Sized + NixRead> NixRead for &mut T

source§

type Error = <T as NixRead>::Error

source§

fn version(&self) -> ProtocolVersion

source§

fn try_read_number( &mut self, ) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send + '_

source§

fn try_read_bytes_limited( &mut self, limit: RangeInclusive<usize>, ) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_

source§

fn try_read_bytes( &mut self, ) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + Send + '_

source§

fn read_number( &mut self, ) -> impl Future<Output = Result<u64, Self::Error>> + Send + '_

source§

fn read_bytes_limited( &mut self, limit: RangeInclusive<usize>, ) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_

source§

fn read_bytes( &mut self, ) -> impl Future<Output = Result<Bytes, Self::Error>> + Send + '_

source§

fn try_read_value<V: NixDeserialize>( &mut self, ) -> impl Future<Output = Result<Option<V>, Self::Error>> + Send + '_

source§

fn read_value<V: NixDeserialize>( &mut self, ) -> impl Future<Output = Result<V, Self::Error>> + Send + '_

Implementors§