[][src]Struct holochain_serialized_bytes::SerializedBytes

pub struct SerializedBytes(_);

A Canonical Serialized Bytes representation for data If you have a data structure that needs a canonical byte representation use this Always round-trip through SerializedBytes via. a single TryFrom implementation. This ensures that the internal bytes of SerializedBytes are indeed canonical. The corrolary is that if bytes are NOT wrapped in SerializedBytes we can assume they are NOT canonical. Typically we need a canonical serialization when data is to be handled at the byte level by independently implemented and maintained systems.

Examples of times we need a canonical set of bytes to represent data:

  • cryptographic operations
  • moving across the host/guest wasm boundary
  • putting data on the network

Examples of times where we may not need a canonical representation and so may not need this:

  • round tripping data through a database that has its own serialization preferences
  • debug output or logging of data that is to be human readible
  • moving between data types within a single system that has no external facing representation

Methods

impl SerializedBytes[src]

pub fn bytes(&self) -> &Vec<u8>[src]

Trait Implementations

impl Clone for SerializedBytes[src]

impl Debug for SerializedBytes[src]

A bit of magic to convert the internal messagepack bytes into roughly equivalent JSON output for the purposes of debugging. 90% of the time you probably want this if you are a dev, to see something that "looks like" a data structure when you do {:?} in a formatted string, rather than a vector of bytes in the remaining 10% of situations where you want to debug the real messagepack bytes, call the .bytes() method on SerializedBytes and debug that.

impl Default for SerializedBytes[src]

impl<'de> Deserialize<'de> for SerializedBytes[src]

impl Eq for SerializedBytes[src]

impl From<SerializedBytes> for UnsafeBytes[src]

impl From<UnsafeBytes> for SerializedBytes[src]

impl Hash for SerializedBytes[src]

impl PartialEq<SerializedBytes> for SerializedBytes[src]

impl Serialize for SerializedBytes[src]

impl StructuralEq for SerializedBytes[src]

impl StructuralPartialEq for SerializedBytes[src]

impl<'_> TryFrom<&'_ ()> for SerializedBytes[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl TryFrom<()> for SerializedBytes[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

impl TryFrom<SerializedBytes> for ()[src]

type Error = SerializedBytesError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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> 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.