pub trait XdrCodec: Sized {
// Required methods
fn to_xdr_buffered(&self, write_stream: &mut WriteStream);
fn from_xdr_buffered<T: AsRef<[u8]>>(
read_stream: &mut ReadStream<T>,
) -> Result<Self, DecodeError>;
// Provided methods
fn to_xdr(&self) -> Vec<u8> ⓘ { ... }
fn from_xdr<T: AsRef<[u8]>>(input: T) -> Result<Self, DecodeError> { ... }
fn to_base64_xdr(&self) -> Vec<u8> ⓘ { ... }
fn from_base64_xdr<T: AsRef<[u8]>>(input: T) -> Result<Self, DecodeError> { ... }
}Expand description
The XDR decoder/encoder trait
A type that implements this trait can be encoded as XDR or decoded from XDR
Required Methods§
Sourcefn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
Encode the XDR to a write stream
This is the basic implementation of the XDR encoder of this type. The methods
to_xdr and to_base64_xdr call this function to do the heavy lifting.
Sourcefn from_xdr_buffered<T: AsRef<[u8]>>(
read_stream: &mut ReadStream<T>,
) -> Result<Self, DecodeError>
fn from_xdr_buffered<T: AsRef<[u8]>>( read_stream: &mut ReadStream<T>, ) -> Result<Self, DecodeError>
Decode the XDR from a read stream
This is the basic implementation of the XDR decoder of this type. The methods
from_xdr and from_base64_xdr call this function to do the heavy lifting.
Provided Methods§
Sourcefn to_xdr(&self) -> Vec<u8> ⓘ
fn to_xdr(&self) -> Vec<u8> ⓘ
Encode this type as XDR
The binary XDR is returned as a byte vector
Sourcefn from_xdr<T: AsRef<[u8]>>(input: T) -> Result<Self, DecodeError>
fn from_xdr<T: AsRef<[u8]>>(input: T) -> Result<Self, DecodeError>
Decode XDR provided as a reference to a byte vector
This will return error if decoding was not successful
Sourcefn to_base64_xdr(&self) -> Vec<u8> ⓘ
fn to_base64_xdr(&self) -> Vec<u8> ⓘ
Encode this type as base64 encoded XDR
This returns an ASCII string (as a byte vector) that is the base64 encoding of the XDR encoding of this type.
Sourcefn from_base64_xdr<T: AsRef<[u8]>>(input: T) -> Result<Self, DecodeError>
fn from_base64_xdr<T: AsRef<[u8]>>(input: T) -> Result<Self, DecodeError>
Decode this type from base64 encoded XDR
This takes a reference to an ASCII string (as a byte vector), decodes it as base64 and then decodes the resulting binary array as XDR.
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.
Implementations on Foreign Types§
Source§impl XdrCodec for bool
Implementation of the XDR decoder/encoder for bool
impl XdrCodec for bool
Implementation of the XDR decoder/encoder for bool
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<T: AsRef<[u8]>>( read_stream: &mut ReadStream<T>, ) -> Result<Self, DecodeError>
Source§impl XdrCodec for i32
Implementation of the XDR decoder/encoder for i32
impl XdrCodec for i32
Implementation of the XDR decoder/encoder for i32
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<T: AsRef<[u8]>>( read_stream: &mut ReadStream<T>, ) -> Result<Self, DecodeError>
Source§impl XdrCodec for i64
Implementation of the XDR decoder/encoder for i64
impl XdrCodec for i64
Implementation of the XDR decoder/encoder for i64
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<T: AsRef<[u8]>>( read_stream: &mut ReadStream<T>, ) -> Result<Self, DecodeError>
Source§impl XdrCodec for u32
Implementation of the XDR decoder/encoder for u32
impl XdrCodec for u32
Implementation of the XDR decoder/encoder for u32
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<T: AsRef<[u8]>>( read_stream: &mut ReadStream<T>, ) -> Result<Self, DecodeError>
Source§impl XdrCodec for u64
Implementation of the XDR decoder/encoder for u64
impl XdrCodec for u64
Implementation of the XDR decoder/encoder for u64
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<T: AsRef<[u8]>>( read_stream: &mut ReadStream<T>, ) -> Result<Self, DecodeError>
Source§impl<T: XdrCodec> XdrCodec for Option<T>
Implementation of the XDR decoder/encoder for an Option.
impl<T: XdrCodec> XdrCodec for Option<T>
Implementation of the XDR decoder/encoder for an Option.
This requires that the inner type already implements XdrCodec
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<R: AsRef<[u8]>>( read_stream: &mut ReadStream<R>, ) -> Result<Self, DecodeError>
Source§impl<T: XdrCodec> XdrCodec for Box<T>
Implementation of the XDR decoder/encoder for an Box.
impl<T: XdrCodec> XdrCodec for Box<T>
Implementation of the XDR decoder/encoder for an Box.
This requires that the inner type already implements XdrCodec
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<R: AsRef<[u8]>>( read_stream: &mut ReadStream<R>, ) -> Result<Self, DecodeError>
Source§impl<T: XdrCodec, const N: usize> XdrCodec for [T; N]
Implementation of the XDR decoder/encoder for a fixed size array
impl<T: XdrCodec, const N: usize> XdrCodec for [T; N]
Implementation of the XDR decoder/encoder for a fixed size array
This requires that the inner type already implements XdrCodec
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<R: AsRef<[u8]>>( read_stream: &mut ReadStream<R>, ) -> Result<Self, DecodeError>
Source§impl<const N: usize> XdrCodec for [u8; N]
Implementation of the XDR decoder/encoder for fixed length binary data
impl<const N: usize> XdrCodec for [u8; N]
Implementation of the XDR decoder/encoder for fixed length binary data