Trait substrate_stellar_sdk::XdrCodec
source · [−]pub trait XdrCodec: Sized {
fn to_xdr_buffered(&self, write_stream: &mut WriteStream);
fn from_xdr_buffered<T: AsRef<[u8]>>(
read_stream: &mut ReadStream<T>
) -> Result<Self, DecodeError>;
fn to_xdr(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
{ ... }
fn from_xdr<T: AsRef<[u8]>>(input: T) -> Result<Self, DecodeError> { ... }
fn to_base64_xdr(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
{ ... }
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
fn 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.
fn 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
Encode this type as XDR
The binary XDR is returned as a byte vector
Decode XDR provided as a reference to a byte vector
This will return error if decoding was not successful
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.
fn 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.
Implementations on Foreign Types
sourceimpl XdrCodec 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>
sourceimpl XdrCodec 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>
sourceimpl XdrCodec 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>
sourceimpl XdrCodec 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>
sourceimpl XdrCodec 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>
sourceimpl<T: XdrCodec, const N: usize> XdrCodec for [T; N]
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>
sourceimpl<const N: usize> XdrCodec for [u8; N]
impl<const N: usize> XdrCodec for [u8; N]
Implementation of the XDR decoder/encoder for fixed length binary data
fn to_xdr_buffered(&self, write_stream: &mut WriteStream)
fn from_xdr_buffered<T: AsRef<[u8]>>(
read_stream: &mut ReadStream<T>
) -> Result<Self, DecodeError>
sourceimpl<T: XdrCodec> XdrCodec for Option<T>
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>
sourceimpl<T: XdrCodec> XdrCodec for Box<T>
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