Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions source/postcard-schema/src/key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ impl Key {
Key(hash::fnv1a64::hash_ty_path::<T>(path))
}

/// Unsafely create a key from a given 8-byte value
/// Create a key from a given 8-byte value
Comment thread
jamesmunns marked this conversation as resolved.
///
/// ## Safety
///
/// This MUST only be used with pre-calculated values. Incorrectly
/// created keys could lead to the improper deserialization of
/// messages.
pub const unsafe fn from_bytes(bytes: [u8; 8]) -> Self {
/// NOTE: Since [`Key`]s should never be used to replace full type safety,
/// creating a "wrong" Key should not be unsafe. However, using a "wrong"
/// key (which doesn't match the type being deserialized) may cause confusion,
/// so manually creating keys should be avoided whenever possible.
pub const fn from_bytes(bytes: [u8; 8]) -> Self {
Self(bytes)
}

Expand Down