Packages
ferricstore
0.11.2
0.11.12
0.11.11
0.11.10
0.11.9
0.11.8
0.11.7
0.11.6
0.11.5
0.11.4
0.11.3
0.11.2
0.11.1
0.11.0
0.10.3
0.10.2
0.10.1
0.10.0
0.9.1
0.9.0
0.8.0
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.2.0
0.1.0
FerricFlow durable workflows and queues with native-protocol storage, Raft durability, and Bitcask persistence.
Current section
Files
Jump to
Current section
Files
native/ferricstore_bitcask/src/flow_physical_key.rs
use sha2::{Digest, Sha256};
use std::borrow::Cow;
const MAX_DIRECT_STATE_KEY_BYTES: usize = 511;
const PHYSICAL_STATE_KEY_PREFIX: &[u8] = b"\0flsk:1:";
pub(crate) fn physical_state_key(logical_state_key: &[u8]) -> Cow<'_, [u8]> {
if logical_state_key.len() <= MAX_DIRECT_STATE_KEY_BYTES {
Cow::Borrowed(logical_state_key)
} else {
let digest = Sha256::digest(logical_state_key);
let mut physical_key = Vec::with_capacity(PHYSICAL_STATE_KEY_PREFIX.len() + digest.len());
physical_key.extend_from_slice(PHYSICAL_STATE_KEY_PREFIX);
physical_key.extend_from_slice(&digest);
Cow::Owned(physical_key)
}
}