[][src]Struct sgx_serialize::SerializeHelper

pub struct SerializeHelper { /* fields omitted */ }

SerializeHelper make it easy to obtain serialize function.

Methods

impl SerializeHelper[src]

pub fn new() -> SerializeHelper[src]

Create a new instance of SerializeHelper

let helper = SerializeHelper::new();

pub fn get_size(&self) -> usize[src]

Get the size of the serialized buffer of the target.

impl SerializeHelper[src]

pub fn encode<E: Serializable>(&self, target: E) -> Option<Vec<u8>>[src]

Use encode to serialize a target type. The target must impl the tarit Serializable. The function return a Option::Some of Vec<u8>, if something error, return Option::None.

#[derive(Serializable, DeSerializable)]
struct TestSturct {
    a1: u32,
    a2: u32,
}
let a = TestEnum::EnumStruct {a1: 2017, a2:829};
let helper = SerializeHelper::new();
let data = helper.encode(a).unwrap();

Auto Trait Implementations

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]