Skip to main content

WorkingSet

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>

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

The pre-commit registry every type resolves against.

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>

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>

Apply one proposal’s operation: Self::update or Self::remove.

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)

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

Whether component id is present after the proposals applied so far.

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>

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>

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>

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>

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>

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>

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>

The components a proposal wrote, in id order.

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

Mark a point to return to.

pub fn rollback(&mut self, checkpoint: Checkpoint)

Undo every update and removal since 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

§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

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

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> IntoSql for T

§

fn into_sql<T>(self) -> Self::Expression
where Self: Sized + AsExpression<T>, T: SqlType + TypedExpressionType,

Convert self to an expression for Diesel’s query builder. Read more
§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. 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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WindowExpressionMethods for T

§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,