Struct WorkingSet
pub struct WorkingSet<'a> { /* private fields */ }Expand description
The AppData components one commit’s proposals touch, each decoded once.
Built from the pre-commit registry and a closure that returns a
component’s bytes before the commit: the group’s extensions, a batch’s
states, or the dictionary with pending proposals applied. Apply each
proposal in order with Self::apply, then take the touched states
with Self::into_states. See the module docs for the
guarantees.
Implementations§
§impl<'a> WorkingSet<'a>
impl<'a> WorkingSet<'a>
pub fn new(
registry: Cow<'a, ComponentRegistry>,
base: impl Fn(ComponentId) -> Option<&'a [u8]> + 'a,
) -> WorkingSet<'a>
pub fn new( registry: Cow<'a, ComponentRegistry>, base: impl Fn(ComponentId) -> Option<&'a [u8]> + 'a, ) -> WorkingSet<'a>
A working set over the pre-commit registry and base, which
returns a component’s bytes before the commit.
pub fn registry(&self) -> &ComponentRegistry
pub fn registry(&self) -> &ComponentRegistry
The pre-commit registry every type resolves against.
pub fn component_type(
&mut self,
id: ComponentId,
) -> Result<ComponentType, ComponentSourceError>
pub fn component_type( &mut self, id: ComponentId, ) -> Result<ComponentType, ComponentSourceError>
The type of component id, as resolved_type gives it: its
well-known type, else the type its registry entry names. Each
registry entry decodes at most once, whether or not its type
resolves.
pub fn component_type_with(
&mut self,
id: ComponentId,
validator: &mut ComponentWriteValidator<'_>,
) -> Result<ComponentType, ComponentSourceError>
pub fn component_type_with( &mut self, id: ComponentId, validator: &mut ComponentWriteValidator<'_>, ) -> Result<ComponentType, ComponentSourceError>
Self::component_type, resolved through validator, which judges
against this set’s registry. A commit’s checks and applies then
decode each registry entry once between them.
pub fn apply(
&mut self,
id: ComponentId,
operation: &AppDataUpdateOperation,
) -> Result<(), ComponentSourceError>
pub fn apply( &mut self, id: ComponentId, operation: &AppDataUpdateOperation, ) -> Result<(), ComponentSourceError>
Apply one proposal’s operation: Self::update or Self::remove.
pub fn update(
&mut self,
id: ComponentId,
payload: &[u8],
) -> Result<(), ComponentSourceError>
pub fn update( &mut self, id: ComponentId, payload: &[u8], ) -> Result<(), ComponentSourceError>
Apply an Update payload to component id’s state after the
proposals applied so far, with the checks and the result of
[apply_app_data_update_payload]. On failure the working set is
unchanged.
pub fn remove(&mut self, id: ComponentId)
pub fn remove(&mut self, id: ComponentId)
Remove component id. A later update starts from no value. Neither
decodes the committed bytes nor resolves the type.
pub fn present(&self, id: ComponentId) -> bool
pub fn present(&self, id: ComponentId) -> bool
Whether component id is present after the proposals applied so far.
pub fn snapshot_len(&self, id: ComponentId) -> Option<usize>
pub fn snapshot_len(&self, id: ComponentId) -> Option<usize>
The serialized length of component id after the proposals applied
so far, without encoding it; None when it is absent.
pub fn encode(
&self,
id: ComponentId,
) -> Result<Option<Zeroizing<Vec<u8>>>, ComponentSourceError>
pub fn encode( &self, id: ComponentId, ) -> Result<Option<Zeroizing<Vec<u8>>>, ComponentSourceError>
The bytes of component id after the proposals applied so far;
None when it is absent. Encodes a changed collection.
pub fn bytes(
&self,
id: ComponentId,
) -> Result<Option<&[u8]>, ComponentSourceError>
pub fn bytes( &self, id: ComponentId, ) -> Result<Option<&[u8]>, ComponentSourceError>
The bytes of component id after the proposals applied so far,
without a copy: its committed bytes until a proposal writes it, then
the scalar a proposal wrote. None when it is absent. Fails with
MismatchedMutation once a proposal changed it as a collection,
whose bytes only Self::encode builds.
pub fn is_empty(
&mut self,
id: ComponentId,
) -> Result<Option<bool>, ComponentSourceError>
pub fn is_empty( &mut self, id: ComponentId, ) -> Result<Option<bool>, ComponentSourceError>
Whether collection id holds no entries after the proposals applied
so far; None when it is absent. Decodes the committed bytes on
first use, and fails as an update does when they do not decode.
pub fn get(
&mut self,
id: ComponentId,
key: &[u8],
) -> Result<Option<&[u8]>, ComponentSourceError>
pub fn get( &mut self, id: ComponentId, key: &[u8], ) -> Result<Option<&[u8]>, ComponentSourceError>
The value of the entry with the TLS-encoded key in collection
id, after the proposals applied so far; None when the component
or the entry is absent. A set element’s value is empty. Decodes the
committed bytes on first use. A registry entry’s value is its raw
bytes, even when the registry does not recognize the entry; read
registry policy with Self::registry_entry.
pub fn registry_entry(
&mut self,
id: ComponentId,
) -> Result<Option<ComponentMetadata>, ComponentSourceError>
pub fn registry_entry( &mut self, id: ComponentId, ) -> Result<Option<ComponentMetadata>, ComponentSourceError>
The registry entry of component id after the proposals applied so
far, as ComponentRegistry::get reads it from that registry:
None when the entry is absent or the registry does not recognize
it.
pub fn resolve_hash(
&mut self,
id: ComponentId,
hash: &TlsKeyHash,
) -> Result<Option<Vec<u8>>, ComponentSourceError>
pub fn resolve_hash( &mut self, id: ComponentId, hash: &TlsKeyHash, ) -> Result<Option<Vec<u8>>, ComponentSourceError>
The element of set id that hash names, after the proposals
applied so far: the 32 bytes of an inbox id or the bytes of a byte
string, as expand_app_data_update_to_changes reports a
RemoveByHash. None when the set is absent, holds no such element,
or id is not a set. Resolves the type first, decodes the committed
bytes and builds the hash index on first use, and fails as that
expansion does when one of them fails.
pub fn touched(&self) -> impl Iterator<Item = ComponentId>
pub fn touched(&self) -> impl Iterator<Item = ComponentId>
The components a proposal wrote, in id order.
pub fn into_states(
self,
) -> Result<BTreeMap<ComponentId, Option<Zeroizing<Vec<u8>>>>, ComponentSourceError>
pub fn into_states( self, ) -> Result<BTreeMap<ComponentId, Option<Zeroizing<Vec<u8>>>>, ComponentSourceError>
The state of each component a proposal wrote: its bytes, or None
once removed. Each collection is encoded once here.
pub fn checkpoint(&mut self) -> Checkpoint
pub fn checkpoint(&mut self) -> Checkpoint
Mark a point to return to.
pub fn rollback(&mut self, checkpoint: Checkpoint)
pub fn rollback(&mut self, checkpoint: Checkpoint)
Undo every update and removal since checkpoint.
pub fn release(&mut self, checkpoint: Checkpoint)
pub fn release(&mut self, checkpoint: Checkpoint)
Keep every change since checkpoint.
Auto Trait Implementations§
impl<'a> Freeze for WorkingSet<'a>
impl<'a> !RefUnwindSafe for WorkingSet<'a>
impl<'a> !Send for WorkingSet<'a>
impl<'a> !Sync for WorkingSet<'a>
impl<'a> Unpin for WorkingSet<'a>
impl<'a> UnsafeUnpin for WorkingSet<'a>
impl<'a> !UnwindSafe for WorkingSet<'a>
Blanket Implementations§
§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read more§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read more§fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoSql for T
impl<T> IntoSql for T
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].