Trait ToBytes

Source
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 u128

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 &T
where T: ToBytes,

Source§

impl<T> ToBytes for Box<T>
where 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 EntityKindTag

Source§

impl ToBytes for MessagePayload

Source§

impl ToBytes for MessageTopicOperation

Source§

impl ToBytes for ContractPackageStatus

Source§

impl ToBytes for PublicKey

Source§

impl ToBytes for Signature

Source§

impl ToBytes for ActivationPoint

Available on crate feature std only.
Source§

impl ToBytes for AddressableEntityIdentifier

Source§

impl ToBytes for Block

Source§

impl ToBytes for BlockBody

Source§

impl ToBytes for BlockGlobalAddr

Source§

impl ToBytes for BlockGlobalAddrTag

Source§

impl ToBytes for BlockHeader

Source§

impl ToBytes for BlockIdentifier

Source§

impl ToBytes for BlockSignatures

Source§

impl ToBytes for ByteCodeAddr

Source§

impl ToBytes for ByteCodeKind

Source§

impl ToBytes for ConsensusProtocolName

Available on crate feature std only.
Source§

impl ToBytes for ContractRuntimeTag

Source§

impl ToBytes for EntityAddr

Source§

impl ToBytes for EntityKind

Source§

impl ToBytes for EntryPointAccess

Source§

impl ToBytes for EntryPointAddr

Source§

impl ToBytes for EntryPointPayment

Source§

impl ToBytes for EntryPointType

Source§

impl ToBytes for EntryPointValue

Source§

impl ToBytes for EraEnd

Source§

impl ToBytes for ExecutableDeployItem

Source§

impl ToBytes for FeeHandling

Available on crate feature std only.
Source§

impl ToBytes for GenesisAccount

Available on crate feature std only.
Source§

impl ToBytes for GlobalStateIdentifier

Source§

impl ToBytes for HoldBalanceHandling

Available on crate feature std only.
Source§

impl ToBytes for InitiatorAddr

Source§

impl ToBytes for Key

Source§

impl ToBytes for KeyTag

Source§

impl ToBytes for LegacyRequiredFinality

Available on crate feature std only.
Source§

impl ToBytes for PackageIdentifier

Source§

impl ToBytes for PackageStatus

Source§

impl ToBytes for Phase

Source§

impl ToBytes for PricingHandling

Available on crate feature std only.
Source§

impl ToBytes for PricingMode

Source§

impl ToBytes for RefundHandling

Available on crate feature std only.
Source§

impl ToBytes for StoredValue

Source§

impl ToBytes for Transaction

Source§

impl ToBytes for TransactionArgs

Source§

impl ToBytes for TransactionEntryPoint

Source§

impl ToBytes for TransactionHash

Source§

impl ToBytes for TransactionInvocationTarget

Source§

impl ToBytes for TransactionRuntimeParams

Source§

impl ToBytes for TransactionScheduling

Source§

impl ToBytes for TransactionTarget

Source§

impl ToBytes for Transfer

Source§

impl ToBytes for ValidatorChange

Source§

impl ToBytes for ExecutionResult

Source§

impl ToBytes for TransformError

Source§

impl ToBytes for TransformKindV2

Source§

impl ToBytes for ExecutionResultV1

Source§

impl ToBytes for OpKind

Source§

impl ToBytes for TransformKindV1

Source§

impl ToBytes for Pointer

Source§

impl ToBytes for TrieMerkleProofStep

Source§

impl ToBytes for BidAddr

Source§

impl ToBytes for BidKind

Source§

impl ToBytes for DelegatorKind

Source§

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

Source§

impl ToBytes for SeigniorageAllocation

Source§

impl ToBytes for UnbondKind

Source§

impl ToBytes for CallStackElement

Source§

impl ToBytes for Caller

Source§

impl ToBytes for SystemEntityType

Source§

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

Source§

impl ToBytes for BalanceHoldAddr

Source§

impl ToBytes for BalanceHoldAddrTag

Source§

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

Source§

impl ToBytes for casper_types::bytesrepr::Error

Source§

impl ToBytes for casper_types::account::action_thresholds::ActionThresholds

Source§

impl ToBytes for casper_types::account::associated_keys::AssociatedKeys

Source§

impl ToBytes for Account

Source§

impl ToBytes for AccountHash

Source§

impl ToBytes for casper_types::account::Weight

Source§

impl ToBytes for casper_types::addressable_entity::action_thresholds::ActionThresholds

Source§

impl ToBytes for casper_types::addressable_entity::associated_keys::AssociatedKeys

Source§

impl ToBytes for MessageTopics

Source§

impl ToBytes for NamedKeyAddr

Source§

impl ToBytes for NamedKeyValue

Source§

impl ToBytes for casper_types::addressable_entity::Weight

Source§

impl ToBytes for Message

Source§

impl ToBytes for MessageAddr

Source§

impl ToBytes for MessageChecksum

Source§

impl ToBytes for MessageTopicSummary

Source§

impl ToBytes for TopicNameHash

Source§

impl ToBytes for ContractHash

Source§

impl ToBytes for ContractPackage

Source§

impl ToBytes for ContractPackageHash

Source§

impl ToBytes for ContractVersionKey

Source§

impl ToBytes for EntryPoint

Source§

impl ToBytes for casper_types::contracts::EntryPoints

Source§

impl ToBytes for ExecutionEffect

Source§

impl ToBytes for NamedKey

Source§

impl ToBytes for Operation

Source§

impl ToBytes for TransformV1

Source§

impl ToBytes for Effects

Source§

impl ToBytes for ExecutionResultV2

Source§

impl ToBytes for TransformV2

Source§

impl ToBytes for AccessRights

Source§

impl ToBytes for AccountConfig

Available on crate feature std only.
Source§

impl ToBytes for AccountsConfig

Available on crate feature std only.
Source§

impl ToBytes for AddressableEntity

Source§

impl ToBytes for AddressableEntityHash

Source§

impl ToBytes for AdministratorAccount

Available on crate feature std only.
Source§

impl ToBytes for Approval

Source§

impl ToBytes for ApprovalsHash

Source§

impl ToBytes for AuctionCosts

Available on crate feature std only.
Source§

impl ToBytes for AvailableBlockRange

Source§

impl ToBytes for BlockBodyV1

Source§

impl ToBytes for BlockBodyV2

Source§

impl ToBytes for BlockHash

Source§

impl ToBytes for BlockHashAndHeight

Source§

impl ToBytes for BlockHeaderV1

Source§

impl ToBytes for BlockHeaderV2

Source§

impl ToBytes for BlockSignaturesV1

Source§

impl ToBytes for BlockSignaturesV2

Source§

impl ToBytes for BlockSyncStatus

Source§

impl ToBytes for BlockSynchronizerStatus

Source§

impl ToBytes for BlockTime

Source§

impl ToBytes for BlockV1

Source§

impl ToBytes for BlockV2

Source§

impl ToBytes for BlockWithSignatures

Source§

impl ToBytes for BrTableCost

Available on crate feature std only.
Source§

impl ToBytes for ByteCode

Source§

impl ToBytes for ByteCodeHash

Source§

impl ToBytes for CLValue

Source§

impl ToBytes for DictionaryValue

Source§

impl ToBytes for ChainNameDigest

Source§

impl ToBytes for Chainspec

Available on crate feature std only.
Source§

impl ToBytes for ChainspecRawBytes

Available on crate feature std only.
Source§

impl ToBytes for ChainspecRegistry

Available on crate feature std only.
Source§

impl ToBytes for ChecksumRegistry

Source§

impl ToBytes for ChunkWithProof

Source§

impl ToBytes for Contract

Source§

impl ToBytes for ContractWasm

Source§

impl ToBytes for ContractWasmHash

Source§

impl ToBytes for ControlFlowCosts

Available on crate feature std only.
Source§

impl ToBytes for CoreConfig

Available on crate feature std only.
Source§

impl ToBytes for DelegatorConfig

Available on crate feature std only.
Source§

impl ToBytes for Deploy

Source§

impl ToBytes for DeployConfig

Available on crate feature std only.
Source§

impl ToBytes for DeployHash

Source§

impl ToBytes for DeployHeader

Source§

impl ToBytes for DeployId

Source§

impl ToBytes for DeployInfo

Source§

impl ToBytes for Digest

Source§

impl ToBytes for EntityEntryPoint

Source§

impl ToBytes for EntityVersionKey

Source§

impl ToBytes for EntityVersions

Source§

impl ToBytes for casper_types::EntryPoints

Source§

impl ToBytes for EraEndV1

Source§

impl ToBytes for EraEndV2

Source§

impl ToBytes for EraId

Source§

impl ToBytes for ExecutionInfo

Source§

impl ToBytes for Gas

Source§

impl ToBytes for GenesisValidator

Available on crate feature std only.
Source§

impl ToBytes for GlobalStateUpdate

Available on crate feature std only.
Source§

impl ToBytes for Group

Source§

impl ToBytes for Groups

Source§

impl ToBytes for HandlePaymentCosts

Available on crate feature std only.
Source§

impl ToBytes for HighwayConfig

Available on crate feature std only.
Source§

impl ToBytes for HostFunctionCostsV1

Available on crate feature std only.
Source§

impl ToBytes for HostFunctionCostsV2

Available on crate feature std only.
Source§

impl ToBytes for IndexedMerkleProof

Source§

impl ToBytes for MessageLimits

Available on crate feature std only.
Source§

impl ToBytes for MintCosts

Available on crate feature std only.
Source§

impl ToBytes for Motes

Source§

impl ToBytes for NamedArg

Source§

impl ToBytes for NamedKeys

Source§

impl ToBytes for NetworkConfig

Available on crate feature std only.
Source§

impl ToBytes for NextUpgrade

Available on crate feature std only.
Source§

impl ToBytes for OpcodeCosts

Available on crate feature std only.
Source§

impl ToBytes for Package

Source§

impl ToBytes for PackageHash

Source§

impl ToBytes for Parameter

Source§

impl ToBytes for PeerEntry

Source§

impl ToBytes for Peers

Source§

impl ToBytes for ProtocolConfig

Available on crate feature std only.
Source§

impl ToBytes for ProtocolVersion

Source§

impl ToBytes for RewardedSignatures

Source§

impl ToBytes for RuntimeArgs

Source§

impl ToBytes for SemVer

Source§

impl ToBytes for SingleBlockRewardedSignatures

Source§

impl ToBytes for StandardPaymentCosts

Available on crate feature std only.
Source§

impl ToBytes for StorageCosts

Available on crate feature std only.
Source§

impl ToBytes for TypeMismatch

Source§

impl ToBytes for SystemConfig

Available on crate feature std only.
Source§

impl ToBytes for SystemHashRegistry

Source§

impl ToBytes for TimeDiff

Source§

impl ToBytes for Timestamp

Source§

impl ToBytes for TransactionConfig

Available on crate feature std only.
Source§

impl ToBytes for TransactionId

Source§

impl ToBytes for TransactionV1

Source§

impl ToBytes for TransactionV1Config

Available on crate feature std only.
Source§

impl ToBytes for TransactionV1Hash

Source§

impl ToBytes for TransactionV1Payload

Source§

impl ToBytes for TransferAddr

Source§

impl ToBytes for TransferV1

Source§

impl ToBytes for TransferV2

Source§

impl ToBytes for U128

Source§

impl ToBytes for U256

Source§

impl ToBytes for U512

Source§

impl ToBytes for URef

Source§

impl ToBytes for VacancyConfig

Available on crate feature std only.
Source§

impl ToBytes for ValidatorConfig

Available on crate feature std only.
Source§

impl ToBytes for WasmConfig

Available on crate feature std only.
Source§

impl ToBytes for WasmV1Config

Available on crate feature std only.
Source§

impl ToBytes for WasmV2Config

Available on crate feature std only.
Source§

impl ToBytes for Bid

Source§

impl ToBytes for Bridge

Source§

impl ToBytes for Delegator

Source§

impl ToBytes for DelegatorBid

Source§

impl ToBytes for EraInfo

Source§

impl ToBytes for Reservation

Source§

impl ToBytes for SeigniorageRecipientV1

Source§

impl ToBytes for SeigniorageRecipientV2

Source§

impl ToBytes for Unbond

Source§

impl ToBytes for UnbondEra

Source§

impl ToBytes for UnbondingPurse

Source§

impl ToBytes for ValidatorBid

Source§

impl ToBytes for ValidatorCredit

Source§

impl ToBytes for WithdrawPurse

Source§

impl ToBytes for PrepaymentKind

Source§

impl ToBytes for CallerInfo

Source§

impl ToBytes for Bytes

Source§

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

Source§

impl<T> ToBytes for HostFunction<T>
where T: AsRef<[Cost]>,

Available on crate feature std only.
Source§

impl<T> ToBytes for HostFunctionV2<T>
where T: AsRef<[u64]>,

Available on crate feature std only.
Source§

impl<VID: ToBytes> ToBytes for EraReport<VID>