pub struct Key(/* private fields */);
Expand description
The Key
uniquely identifies what “kind” of message this is.
In order to generate it, postcard-rpc
takes two pieces of data:
- a
&str
“path” URI, similar to how you would use URIs as part of an HTTP path - The schema of the message type itself, using the experimental schema feature of
postcard
.
Specifically, we use Fnv1a
,
and produce a 64-bit digest, by first hashing the path, then hashing the
schema. Fnv1a is a non-cryptographic hash function, designed to be reasonably
efficient to compute even on small platforms like microcontrollers.
Changing anything about either of the path or the schema will produce
a drastically different Key
value.
Implementations§
Source§impl Key
impl Key
Sourcepub fn for_owned_schema_path(path: &str, nt: &OwnedNamedType) -> Key
pub fn for_owned_schema_path(path: &str, nt: &OwnedNamedType) -> Key
Calculate the Key for the given path and OwnedNamedType
Source§impl Key
impl Key
Sourcepub const unsafe fn from_bytes(bytes: [u8; 8]) -> Self
pub const unsafe fn from_bytes(bytes: [u8; 8]) -> Self
Unsafely create a key from a given 8-byte value
§Safety
This MUST only be used with pre-calculated values. Incorrectly created keys could lead to the improper deserialization of messages.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Key
impl<'de> Deserialize<'de> for Key
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Key
impl Ord for Key
Source§impl PartialOrd for Key
impl PartialOrd for Key
impl Copy for Key
impl Eq for Key
impl StructuralPartialEq for Key
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more