pub trait ToBytes {
    // Required methods
    fn to_bytes(&self) -> Result<Vec<u8>, Error>;
    fn serialized_length(&self) -> usize;

    // Provided methods
    fn into_bytes(self) -> Result<Vec<u8>, Error>
       where Self: Sized { ... }
    fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error> { ... }
}
Expand description

A type which can be serialized to a Vec<u8>.

Required Methods§

source

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes &self to a Vec<u8>.

source

fn serialized_length(&self) -> usize

Returns the length of the Vec<u8> which would be returned from a successful call to to_bytes() or into_bytes(). The data is not actually serialized, so this call is relatively cheap.

Provided Methods§

source

fn into_bytes(self) -> Result<Vec<u8>, Error>where Self: Sized,

Consumes self and serializes to a Vec<u8>.

source

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

Writes &self into a mutable writer.

Implementations on Foreign Types§

source§

impl ToBytes for &str

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for bool

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for i32

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for i64

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for str

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for u8

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for u16

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for u32

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for u64

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for ()

source§

impl ToBytes for String

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl ToBytes for [U512; 14]

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl<K, V> ToBytes for BTreeMap<K, V>where K: ToBytes, V: ToBytes,

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl<T1: ToBytes> ToBytes for (T1,)

source§

impl<T1: ToBytes, T2: ToBytes> ToBytes for (T1, T2)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes> ToBytes for (T1, T2, T3)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes, T4: ToBytes> ToBytes for (T1, T2, T3, T4)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes, T4: ToBytes, T5: ToBytes> ToBytes for (T1, T2, T3, T4, T5)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes, T4: ToBytes, T5: ToBytes, T6: ToBytes> ToBytes for (T1, T2, T3, T4, T5, T6)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes, T4: ToBytes, T5: ToBytes, T6: ToBytes, T7: ToBytes> ToBytes for (T1, T2, T3, T4, T5, T6, T7)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes, T4: ToBytes, T5: ToBytes, T6: ToBytes, T7: ToBytes, T8: ToBytes> ToBytes for (T1, T2, T3, T4, T5, T6, T7, T8)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes, T4: ToBytes, T5: ToBytes, T6: ToBytes, T7: ToBytes, T8: ToBytes, T9: ToBytes> ToBytes for (T1, T2, T3, T4, T5, T6, T7, T8, T9)

source§

impl<T1: ToBytes, T2: ToBytes, T3: ToBytes, T4: ToBytes, T5: ToBytes, T6: ToBytes, T7: ToBytes, T8: ToBytes, T9: ToBytes, T10: ToBytes> ToBytes for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

source§

impl<T> ToBytes for &Twhere T: ToBytes,

source§

impl<T> ToBytes for Ratio<T>where T: Clone + Integer + ToBytes,

source§

impl<T: ToBytes> ToBytes for Option<T>

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl<T: ToBytes> ToBytes for VecDeque<T>

source§

impl<T: ToBytes> ToBytes for Vec<T>

source§

impl<T: ToBytes, E: ToBytes> ToBytes for Result<T, E>

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl<V: ToBytes> ToBytes for BTreeSet<V>

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

source§

impl<const COUNT: usize> ToBytes for [u8; COUNT]

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

source§

fn serialized_length(&self) -> usize

source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

Implementors§

source§

impl ToBytes for ContractPackageStatus

source§

impl ToBytes for PublicKey

source§

impl ToBytes for Signature

source§

impl ToBytes for EntryPointAccess

source§

impl ToBytes for EntryPointType

source§

impl ToBytes for ExecutionResult

source§

impl ToBytes for Key

source§

impl ToBytes for OpKind

source§

impl ToBytes for Phase

source§

impl ToBytes for StoredValue

source§

impl ToBytes for Transform

source§

impl ToBytes for casper_types::system::auction::Error

source§

impl ToBytes for SeigniorageAllocation

source§

impl ToBytes for CallStackElement

source§

impl ToBytes for casper_types::system::handle_payment::Error

source§

impl ToBytes for casper_types::system::mint::Error

source§

impl ToBytes for ActionThresholds

source§

impl ToBytes for AssociatedKeys

source§

impl ToBytes for Account

source§

impl ToBytes for AccountHash

source§

impl ToBytes for Weight

source§

impl ToBytes for AccessRights

source§

impl ToBytes for BlockTime

source§

impl ToBytes for CLValue

source§

impl ToBytes for Contract

source§

impl ToBytes for ContractHash

source§

impl ToBytes for ContractPackage

source§

impl ToBytes for ContractPackageHash

source§

impl ToBytes for ContractVersionKey

source§

impl ToBytes for ContractWasm

source§

impl ToBytes for ContractWasmHash

source§

impl ToBytes for DeployHash

source§

impl ToBytes for DeployInfo

source§

impl ToBytes for EntryPoint

source§

impl ToBytes for EntryPoints

source§

impl ToBytes for EraId

source§

impl ToBytes for ExecutionEffect

source§

impl ToBytes for Group

source§

impl ToBytes for Motes

source§

impl ToBytes for NamedArg

source§

impl ToBytes for NamedKey

source§

impl ToBytes for Operation

source§

impl ToBytes for Parameter

source§

impl ToBytes for ProtocolVersion

source§

impl ToBytes for RuntimeArgs

source§

impl ToBytes for SemVer

source§

impl ToBytes for TimeDiff

source§

impl ToBytes for Timestamp

source§

impl ToBytes for Transfer

source§

impl ToBytes for TransferAddr

source§

impl ToBytes for TransformEntry

source§

impl ToBytes for U128

source§

impl ToBytes for U256

source§

impl ToBytes for U512

source§

impl ToBytes for URef

source§

impl ToBytes for Bid

source§

impl ToBytes for Delegator

source§

impl ToBytes for EraInfo

source§

impl ToBytes for SeigniorageRecipient

source§

impl ToBytes for UnbondingPurse

source§

impl ToBytes for WithdrawPurse

source§

impl ToBytes for Bytes