[−][src]Struct holochain_wasmer_guest::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
uses #[repr(transparent)] to maximise compatibility with ffi @see https://doc.rust-lang.org/1.26.2/unstable-book/language-features/repr-transparent.html#enter-reprtransparent
uses serde_bytes for efficient serialization and deserialization without this every byte will be individually round tripped through serde @see https://crates.io/crates/serde_bytes
Implementations
impl SerializedBytes
[src]
Trait Implementations
impl Clone for SerializedBytes
[src]
fn clone(&self) -> SerializedBytes
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
fn default() -> SerializedBytes
[src]
impl<'de> Deserialize<'de> for SerializedBytes
[src]
fn deserialize<__D>(
__deserializer: __D
) -> Result<SerializedBytes, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<SerializedBytes, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl Eq for SerializedBytes
[src]
impl From<SerializedBytes> for UnsafeBytes
[src]
fn from(sb: SerializedBytes) -> UnsafeBytes
[src]
impl From<UnsafeBytes> for SerializedBytes
[src]
fn from(b: UnsafeBytes) -> SerializedBytes
[src]
impl Hash for SerializedBytes
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<SerializedBytes> for SerializedBytes
[src]
fn eq(&self, other: &SerializedBytes) -> bool
[src]
fn ne(&self, other: &SerializedBytes) -> bool
[src]
impl Serialize for SerializedBytes
[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
impl<'_> TryFrom<&'_ ()> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: &()) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl<'_> TryFrom<&'_ WasmError> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: &WasmError) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl<'_> TryFrom<&'_ WasmResult> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: &WasmResult) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl TryFrom<()> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: ()) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl TryFrom<SerializedBytes> for ()
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(sb: SerializedBytes) -> Result<(), SerializedBytesError>
[src]
impl TryFrom<SerializedBytes> for WasmError
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(sb: SerializedBytes) -> Result<WasmError, SerializedBytesError>
[src]
impl TryFrom<SerializedBytes> for WasmResult
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(sb: SerializedBytes) -> Result<WasmResult, SerializedBytesError>
[src]
impl TryFrom<WasmError> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: WasmError) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl TryFrom<WasmResult> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
fn try_from(t: WasmResult) -> Result<SerializedBytes, SerializedBytesError>
[src]
Auto Trait Implementations
impl RefUnwindSafe for SerializedBytes
impl Send for SerializedBytes
impl Sync for SerializedBytes
impl Unpin for SerializedBytes
impl UnwindSafe for SerializedBytes
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,