Skip to main content

AsyncVersionedMap

Struct AsyncVersionedMap 

Source
pub struct AsyncVersionedMap<'a, S: AsyncStore> { /* private fields */ }
Expand description

Async counterpart to VersionedMap for remote and browser stores.

Implementations§

Source§

impl<'a, S: AsyncStore> AsyncVersionedMap<'a, S>

Source

pub fn new(prolly: &'a AsyncProlly<S>, id: impl AsRef<[u8]>) -> Self

Create an async managed-map handle.

Source

pub fn id(&self) -> &[u8]

Application map identifier.

Source

pub fn head_name(&self) -> &[u8]

Full durable named-root key used for the current head.

Source

pub fn versions_prefix(&self) -> &[u8]

Prefix containing this map’s immutable version roots.

Source

pub fn version_root_name(&self, id: &MapVersionId) -> Vec<u8>

Full durable named-root key for one content-derived version.

Source§

impl<'a, S> AsyncVersionedMap<'a, S>

Source

pub async fn head(&self) -> Result<Option<MapVersion>, Error>

Load current async head.

Source

pub async fn version( &self, id: &MapVersionId, ) -> Result<Option<MapVersion>, Error>

Load a cataloged immutable version.

Source

pub async fn snapshot(&self) -> Result<Option<AsyncMapSnapshot<'a, S>>, Error>

Pin current head for repeatable async reads.

Source

pub async fn snapshot_at( &self, id: &MapVersionId, ) -> Result<Option<AsyncMapSnapshot<'a, S>>, Error>

Pin one cataloged historical version for repeatable async reads.

Source

pub async fn subscribe( &self, ) -> Result<AsyncMapChangeSubscription<'a, S>, Error>

Start observing future async head transitions from the current head.

Source

pub fn subscribe_from( &self, last_seen: Option<MapVersionId>, ) -> AsyncMapChangeSubscription<'a, S>

Resume async observation from a previously persisted version.

Source

pub async fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error>

Read one key from current head.

Source

pub async fn get_large_value<B>( &self, blob_store: &B, key: &[u8], ) -> Result<Option<Vec<u8>>, Error>
where B: AsyncBlobStore, B::Error: Send + Sync,

Read one inline or blob-backed value from current head.

Source§

impl<S> AsyncVersionedMap<'_, S>

Source

pub async fn versions_page( &self, cursor: Option<&MapVersionCursor>, limit: usize, ) -> Result<MapVersionPage, Error>

List a bounded page of cataloged versions in stable version-ID order.

Unlike Self::versions, this method never needs to enumerate other maps’ roots. Cloud backends can implement it as one bounded range query.

Source

pub async fn versions(&self) -> Result<Vec<MapVersion>, Error>

List cataloged versions newest first.

Source§

impl<S> AsyncVersionedMap<'_, S>

Source

pub async fn diff( &self, base: &MapVersionId, target: &MapVersionId, ) -> Result<Vec<Diff>, Error>

Diff two cataloged immutable versions.

Source

pub async fn diff_page( &self, base: &MapVersionId, target: &MapVersionId, cursor: &RangeCursor, end: Option<&[u8]>, limit: usize, ) -> Result<DiffPage, Error>

Read one resumable key-cursor page between cataloged versions.

Source

pub async fn structural_diff_page( &self, base: &MapVersionId, target: &MapVersionId, cursor: Option<&StructuralDiffCursor>, limit: usize, ) -> Result<StructuralDiffPage, Error>

Read one resumable structural page between cataloged versions.

Source

pub async fn changes_since( &self, base: &MapVersionId, ) -> Result<Vec<Diff>, Error>

Diff one cataloged version against current head.

Source

pub async fn apply(&self, mutations: Vec<Mutation>) -> Result<MapVersion, Error>

Atomically apply a batch and retry optimistic head conflicts.

Source

pub async fn apply_at_millis( &self, mutations: Vec<Mutation>, timestamp_millis: u64, ) -> Result<MapVersion, Error>

Atomically apply a batch with an explicit catalog timestamp.

Source

pub async fn apply_if( &self, expected: Option<&MapVersionId>, mutations: Vec<Mutation>, ) -> Result<VersionedMapUpdate, Error>

Apply a batch only when expected is still the current version.

Source

pub async fn apply_if_at_millis( &self, expected: Option<&MapVersionId>, mutations: Vec<Mutation>, timestamp_millis: u64, ) -> Result<VersionedMapUpdate, Error>

Apply a batch only when expected is still the current version, with an explicit catalog timestamp.

Source

pub async fn restore_if( &self, expected: Option<&MapVersionId>, target: &MapVersionId, ) -> Result<VersionedMapUpdate, Error>

Move head to an existing version when expected is still current.

The target must remain in the immutable version catalog. A concurrent head movement is reported as VersionedMapUpdate::Conflict.

Source

pub async fn put( &self, key: impl Into<Vec<u8>>, value: impl Into<Vec<u8>>, ) -> Result<MapVersion, Error>

Put one key asynchronously.

Source

pub async fn put_large_value<B>( &self, blob_store: &B, key: impl Into<Vec<u8>>, value: impl Into<Vec<u8>>, config: LargeValueConfig, ) -> Result<MapVersion, Error>
where B: AsyncBlobStore, B::Error: Send + Sync,

Put one value, offloading large bytes, and retry head conflicts.

Source

pub async fn delete(&self, key: impl Into<Vec<u8>>) -> Result<MapVersion, Error>

Delete one key asynchronously.

Source

pub async fn edit( &self, edit: impl FnOnce(&mut VersionedMapEditor), ) -> Result<MapVersion, Error>

Collect and apply several asynchronous managed-map edits.

Source§

impl<S> AsyncVersionedMap<'_, S>

Source

pub async fn prune_versions( &self, keep_latest: usize, ) -> Result<VersionPruneResult, Error>

Keep the newest keep_latest versions plus the current head.

Source

pub async fn keep_last(&self, count: usize) -> Result<VersionPruneResult, Error>

Retain the newest count versions plus the current head.

Source

pub async fn keep_for( &self, max_age: Duration, ) -> Result<VersionPruneResult, Error>

Retain versions newer than max_age plus the current head.

Source

pub async fn keep_for_at( &self, now_millis: u64, max_age: Duration, ) -> Result<VersionPruneResult, Error>

Deterministic form of AsyncVersionedMap::keep_for with an explicit clock.

Source

pub async fn keep_versions<I, V>( &self, ids: I, ) -> Result<VersionPruneResult, Error>
where I: IntoIterator<Item = V>, V: Borrow<MapVersionId>,

Retain an explicit version set plus the current head.

Missing requested IDs are rejected so a typo cannot silently discard more history than intended.

Auto Trait Implementations§

§

impl<'a, S> Freeze for AsyncVersionedMap<'a, S>
where &'a ProllyEngine<S>: Freeze,

§

impl<'a, S> RefUnwindSafe for AsyncVersionedMap<'a, S>

§

impl<'a, S> Send for AsyncVersionedMap<'a, S>
where &'a ProllyEngine<S>: Send,

§

impl<'a, S> Sync for AsyncVersionedMap<'a, S>
where &'a ProllyEngine<S>: Sync,

§

impl<'a, S> Unpin for AsyncVersionedMap<'a, S>
where &'a ProllyEngine<S>: Unpin,

§

impl<'a, S> UnsafeUnpin for AsyncVersionedMap<'a, S>
where &'a ProllyEngine<S>: UnsafeUnpin,

§

impl<'a, S> UnwindSafe for AsyncVersionedMap<'a, S>
where &'a ProllyEngine<S>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.