Struct holochain_state::scratch::Scratch
source · [−]pub struct Scratch { /* private fields */ }
Expand description
The “scratch” is an in-memory space to stage Headers to be committed at the end of the CallZome workflow.
This space must also be queryable: specifically, it needs to be combined into queries into the database which return Headers. This is done by a simple filter on the scratch space, and then chaining that iterator onto the iterators over the Headers in the database(s) produced by the Cascade.
Implementations
sourceimpl Scratch
impl Scratch
pub fn new() -> Self
pub fn scheduled_fns(&self) -> &[ScheduledFn]
pub fn add_scheduled_fn(&mut self, scheduled_fn: ScheduledFn)
pub fn chain_top_ordering(&self) -> ChainTopOrdering
pub fn respect_chain_top_ordering(
&mut self,
chain_top_ordering: ChainTopOrdering
)
pub fn add_header(
&mut self,
zome: Option<Zome>,
item: SignedHeaderHashed,
chain_top_ordering: ChainTopOrdering
)
pub fn chain_head(&self) -> Option<(HeaderHash, u32, Timestamp)>
pub fn add_entry(
&mut self,
entry_hashed: EntryHashed,
chain_top_ordering: ChainTopOrdering
)
pub fn as_filter(
&self,
f: impl Fn(&SignedHeaderHashed) -> bool
) -> FilteredScratch
pub fn into_sync(self) -> SyncScratch
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn headers(&self) -> impl Iterator<Item = &SignedHeaderHashed>
pub fn elements(&self) -> impl Iterator<Item = Element> + '_
sourcepub fn entries(&self) -> impl Iterator<Item = (&EntryHash, &Arc<Entry>)>
pub fn entries(&self) -> impl Iterator<Item = (&EntryHash, &Arc<Entry>)>
Get the entries on in the scratch.
pub fn num_headers(&self) -> usize
pub fn drain_scheduled_fns(&mut self) -> impl Iterator<Item = ScheduledFn> + '_
sourcepub fn drain_zomed_headers(
&mut self
) -> impl Iterator<Item = (Option<Zome>, SignedHeaderHashed)> + '_
pub fn drain_zomed_headers(
&mut self
) -> impl Iterator<Item = (Option<Zome>, SignedHeaderHashed)> + '_
Drain out all the headers.
sourcepub fn drain_entries(&mut self) -> impl Iterator<Item = EntryHashed> + '_
pub fn drain_entries(&mut self) -> impl Iterator<Item = EntryHashed> + '_
Drain out all the entries.
Trait Implementations
sourceimpl Store for Scratch
impl Store for Scratch
It doesn’t make sense to search for
a different authored entry in a scratch
then the scratches author so this is
the same as get_entry
.
It doesn’t make sense to search for
a different authored element in a scratch
then the scratches author so this is
the same as get_element
.
sourcefn get_entry(&self, hash: &EntryHash) -> StateQueryResult<Option<Entry>>
fn get_entry(&self, hash: &EntryHash) -> StateQueryResult<Option<Entry>>
Get an Entry
from this store.
sourcefn contains_entry(&self, hash: &EntryHash) -> StateQueryResult<bool>
fn contains_entry(&self, hash: &EntryHash) -> StateQueryResult<bool>
Check if an entry is contained in the store
sourcefn contains_header(&self, hash: &HeaderHash) -> StateQueryResult<bool>
fn contains_header(&self, hash: &HeaderHash) -> StateQueryResult<bool>
Check if a header is contained in the store
sourcefn get_header(
&self,
hash: &HeaderHash
) -> StateQueryResult<Option<SignedHeaderHashed>>
fn get_header(
&self,
hash: &HeaderHash
) -> StateQueryResult<Option<SignedHeaderHashed>>
Get an SignedHeaderHashed
from this store.
sourcefn get_element(&self, hash: &AnyDhtHash) -> StateQueryResult<Option<Element>>
fn get_element(&self, hash: &AnyDhtHash) -> StateQueryResult<Option<Element>>
Get an Element
from this store.
sourcefn contains_hash(&self, hash: &AnyDhtHash) -> StateQueryResult<bool>
fn contains_hash(&self, hash: &AnyDhtHash) -> StateQueryResult<bool>
Check if a hash is contained in the store
sourceimpl<Q> Stores<Q> for Scratch where
Q: Query<Item = Judged<SignedHeaderHashed>>,
impl<Q> Stores<Q> for Scratch where
Q: Query<Item = Judged<SignedHeaderHashed>>,
type O = FilteredScratch
sourcefn get_initial_data(&self, query: Q) -> StateQueryResult<Self::O>
fn get_initial_data(&self, query: Q) -> StateQueryResult<Self::O>
Gets the raw initial data from the database, needed to begin the query.
Auto Trait Implementations
impl !RefUnwindSafe for Scratch
impl Send for Scratch
impl Sync for Scratch
impl Unpin for Scratch
impl !UnwindSafe for Scratch
Blanket Implementations
impl<T> Any for T where
T: Any + ?Sized,
impl<T> Any for T where
T: Any + ?Sized,
fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
TODO: once 1.33.0 is the minimum supported compiler version, remove Any::type_id_compat and use StdAny::type_id instead. https://github.com/rust-lang/rust/issues/27745 Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more