[−][src]Struct holochain_wasmer_common::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]
pub fn clone(&self) -> SerializedBytes
[src]
pub 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]
pub fn default() -> SerializedBytes
[src]
impl<'de> Deserialize<'de> for SerializedBytes
[src]
pub 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]
pub fn from(sb: SerializedBytes) -> UnsafeBytes
[src]
impl From<UnsafeBytes> for SerializedBytes
[src]
pub fn from(b: UnsafeBytes) -> SerializedBytes
[src]
impl Hash for SerializedBytes
[src]
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for SerializedBytes
[src]
pub fn cmp(&self, other: &SerializedBytes) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<SerializedBytes> for SerializedBytes
[src]
pub fn eq(&self, other: &SerializedBytes) -> bool
[src]
pub fn ne(&self, other: &SerializedBytes) -> bool
[src]
impl PartialOrd<SerializedBytes> for SerializedBytes
[src]
pub fn partial_cmp(&self, other: &SerializedBytes) -> Option<Ordering>
[src]
pub fn lt(&self, other: &SerializedBytes) -> bool
[src]
pub fn le(&self, other: &SerializedBytes) -> bool
[src]
pub fn gt(&self, other: &SerializedBytes) -> bool
[src]
pub fn ge(&self, other: &SerializedBytes) -> bool
[src]
impl Serialize for SerializedBytes
[src]
pub 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 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.
pub 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.
pub 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.
pub fn try_from(t: &WasmResult) -> Result<SerializedBytes, SerializedBytesError>
[src]
impl<'a> TryFrom<&'a SerializedBytes> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
pub fn try_from(
s: &'a SerializedBytes
) -> Result<SerializedBytes, <SerializedBytes as TryFrom<&'a SerializedBytes>>::Error>
[src]
s: &'a SerializedBytes
) -> Result<SerializedBytes, <SerializedBytes as TryFrom<&'a SerializedBytes>>::Error>
impl TryFrom<()> for SerializedBytes
[src]
type Error = SerializedBytesError
The type returned in the event of a conversion error.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub fn try_from(t: WasmResult) -> Result<SerializedBytes, SerializedBytesError>
[src]
Auto Trait Implementations
impl RefUnwindSafe for SerializedBytes
[src]
impl Send for SerializedBytes
[src]
impl Sync for SerializedBytes
[src]
impl Unpin for SerializedBytes
[src]
impl UnwindSafe for SerializedBytes
[src]
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,
pub 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,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,