pub enum KeyspaceHandle {
Local(LocalKeyspaceHandle),
}Expand description
Handle to a keyspace with optional transparent encryption.
Wraps either a local fjall keyspace or a vsock-proxied keyspace. Encryption is always applied locally (before data leaves the enclave).
Variants§
Local(LocalKeyspaceHandle)
Implementations§
Source§impl KeyspaceHandle
impl KeyspaceHandle
pub fn is_encrypted(&self) -> bool
Sourcepub async fn persist(&self) -> Result<(), AppError>
pub async fn persist(&self) -> Result<(), AppError>
Durably flush the store to disk (a write barrier).
Persistence is store-wide, not per-keyspace: the local backend fsyncs the shared fjall journal, the vsock backend asks the parent proxy to flush. Call after security-critical writes whose loss on crash would violate an invariant (carve-out close, counter allocation) — once this returns, the writes survive power loss.
pub async fn insert<V: Serialize>( &self, key: impl Into<Vec<u8>>, value: &V, ) -> Result<(), AppError>
Sourcepub async fn insert_if_absent<V: Serialize>(
&self,
key: impl Into<Vec<u8>>,
value: &V,
) -> Result<bool, AppError>
pub async fn insert_if_absent<V: Serialize>( &self, key: impl Into<Vec<u8>>, value: &V, ) -> Result<bool, AppError>
Insert value at key only if key is currently absent.
Returns true when the insert happened, false when the key
already existed (the stored value is left untouched).
On the KeyspaceHandle::Local variant the check and insert
run inside one blocking closure, so exactly one of two racing
callers observes true. On the [KeyspaceHandle::Vsock]
variant the vsock RPC does not yet carry a native
insert-if-absent opcode; the fallback is get_raw + insert,
which has a TOCTOU window across two vsock round-trips — the
same documented gap as KeyspaceHandle::take_raw (TEE
enclaves are single-replica, so the window is per-connection
rather than cross-replica).
Sourcepub async fn insert_raw_if_absent(
&self,
key: impl Into<Vec<u8>>,
value: impl Into<Vec<u8>>,
) -> Result<bool, AppError>
pub async fn insert_raw_if_absent( &self, key: impl Into<Vec<u8>>, value: impl Into<Vec<u8>>, ) -> Result<bool, AppError>
Raw-bytes variant of KeyspaceHandle::insert_if_absent — same
semantics and the same vsock TOCTOU caveat, for values that are
stored via insert_raw/get_raw rather than as serde JSON.
pub async fn get<V: DeserializeOwned + Send + 'static>( &self, key: impl Into<Vec<u8>>, ) -> Result<Option<V>, AppError>
pub async fn remove(&self, key: impl Into<Vec<u8>>) -> Result<(), AppError>
Sourcepub async fn take_raw(
&self,
key: impl Into<Vec<u8>>,
) -> Result<Option<Vec<u8>>, AppError>
pub async fn take_raw( &self, key: impl Into<Vec<u8>>, ) -> Result<Option<Vec<u8>>, AppError>
Atomic GET + DELETE — see
LocalKeyspaceHandle::take_raw.
On the [KeyspaceHandle::Vsock] variant the vsock RPC does
not yet carry a native take opcode. The fallback is
get_raw + remove, which has a TOCTOU window across two
vsock round-trips — two concurrent presenters could both
observe Some. The canonical refresh-token claim treats
this as a documented gap (TEE enclaves are single-replica,
so the window is per-connection rather than cross-replica)
and emits a warn! on every call so it stays visible
until the vsock proto gains a take opcode.
pub async fn insert_raw( &self, key: impl Into<Vec<u8>>, value: impl Into<Vec<u8>>, ) -> Result<(), AppError>
pub async fn get_raw( &self, key: impl Into<Vec<u8>>, ) -> Result<Option<Vec<u8>>, AppError>
pub async fn prefix_iter_raw( &self, prefix: impl Into<Vec<u8>>, ) -> Result<Vec<RawKvPair>, AppError>
Sourcepub async fn range_from_raw(
&self,
from: impl Into<Vec<u8>>,
) -> Result<Vec<RawKvPair>, AppError>
pub async fn range_from_raw( &self, from: impl Into<Vec<u8>>, ) -> Result<Vec<RawKvPair>, AppError>
Iterate key/value pairs whose key is >= from (inclusive lower
bound, unbounded above), in ascending key order. Unlike
Self::prefix_iter_raw this seeks to from rather than
scanning from the start of the keyspace — used by the registry
syncer’s audit-tail walk to skip already-processed history
(audit keys are <rfc3339-ts>:<event_id>, which sort
chronologically), so per-tick cost is proportional to new rows
rather than the whole audit log.
pub async fn prefix_keys( &self, prefix: impl Into<Vec<u8>>, ) -> Result<Vec<Vec<u8>>, AppError>
pub async fn approximate_len(&self) -> Result<usize, AppError>
pub async fn swap<V: Serialize>( &self, old_key: impl Into<Vec<u8>>, new_key: impl Into<Vec<u8>>, value: &V, ) -> Result<bool, AppError>
Trait Implementations§
Source§impl Clone for KeyspaceHandle
impl Clone for KeyspaceHandle
Source§fn clone(&self) -> KeyspaceHandle
fn clone(&self) -> KeyspaceHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for KeyspaceHandle
impl !UnwindSafe for KeyspaceHandle
impl Freeze for KeyspaceHandle
impl Send for KeyspaceHandle
impl Sync for KeyspaceHandle
impl Unpin for KeyspaceHandle
impl UnsafeUnpin for KeyspaceHandle
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
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
T.