Trait borsh::ser::BorshSerialize[][src]

pub trait BorshSerialize {
    fn serialize<W: Write>(&self, writer: &mut W) -> Result<()>;

    fn try_to_vec(&self) -> Result<Vec<u8>> { ... }
}
Expand description

A data-structure that can be serialized into binary format by NBOR.

use borsh::BorshSerialize;

#[derive(BorshSerialize)]
struct MyBorshSerializableStruct {
    value: String,
}

let x = MyBorshSerializableStruct { value: "hello".to_owned() };
let mut buffer: Vec<u8> = Vec::new();
x.serialize(&mut buffer).unwrap();
let single_serialized_buffer_len = buffer.len();

x.serialize(&mut buffer).unwrap();
assert_eq!(buffer.len(), single_serialized_buffer_len * 2);

let mut buffer: Vec<u8> = vec![0; 1024 + single_serialized_buffer_len];
let mut buffer_slice_enough_for_the_data = &mut buffer[1024..1024 + single_serialized_buffer_len];
x.serialize(&mut buffer_slice_enough_for_the_data).unwrap();

Required methods

Provided methods

Serialize this instance into a vector of bytes.

Implementations on Foreign Types

Implementors

impl BorshSerialize for AgnosticOrderbookInstruction where
    Params: BorshSerialize,
    Params: BorshSerialize,
    Params: BorshSerialize,
    Params: BorshSerialize

impl BorshSerialize for AccountTag

impl BorshSerialize for Side

impl BorshSerialize for SelfTradeBehavior

impl BorshSerialize for MarketState where
    AccountTag: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize

impl BorshSerialize for Event where
    Side: BorshSerialize,
    u128: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    Vec<u8>: BorshSerialize,
    Vec<u8>: BorshSerialize,
    Side: BorshSerialize,
    u128: BorshSerialize,
    u64: BorshSerialize,
    bool: BorshSerialize,
    Vec<u8>: BorshSerialize

impl BorshSerialize for EventQueueHeader where
    AccountTag: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u32: BorshSerialize

impl BorshSerialize for OrderSummary where
    Option<u128>: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize

impl BorshSerialize for Params where
    u128: BorshSerialize

impl BorshSerialize for Params

impl BorshSerialize for Params where
    u64: BorshSerialize

impl BorshSerialize for Params where
    Pubkey: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize

impl BorshSerialize for Params where
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    Side: BorshSerialize,
    u64: BorshSerialize,
    Vec<u8>: BorshSerialize,
    bool: BorshSerialize,
    bool: BorshSerialize,
    SelfTradeBehavior: BorshSerialize

impl BorshSerialize for DexInstruction where
    Params: BorshSerialize,
    Params: BorshSerialize,
    Params: BorshSerialize,
    Params: BorshSerialize,
    Params: BorshSerialize,
    Params: BorshSerialize

impl BorshSerialize for AccountTag

impl BorshSerialize for Side

impl BorshSerialize for SelfTradeBehavior

impl BorshSerialize for DexState where
    AccountTag: BorshSerialize,
    u8: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    i64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize

impl BorshSerialize for UserAccountHeader where
    AccountTag: BorshSerialize,
    Pubkey: BorshSerialize,
    Pubkey: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u32: BorshSerialize

impl BorshSerialize for Params where
    u64: BorshSerialize,
    u128: BorshSerialize

impl BorshSerialize for Params where
    u64: BorshSerialize

impl BorshSerialize for Params where
    u8: BorshSerialize,
    u64: BorshSerialize

impl BorshSerialize for Params where
    Pubkey: BorshSerialize,
    u64: BorshSerialize

impl BorshSerialize for Params where
    Side: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    u64: BorshSerialize,
    OrderType: BorshSerialize,
    SelfTradeBehavior: BorshSerialize,
    u64: BorshSerialize

impl BorshSerialize for OrderType

impl BorshSerialize for Params

impl BorshSerialize for Params

impl BorshSerialize for Params

impl BorshSerialize for Hash

impl BorshSerialize for Hash

impl BorshSerialize for Pubkey

impl BorshSerialize for Secp256k1Pubkey