pub struct OpLog { /* private fields */ }Expand description
In-memory log and peer cursors (the last seq applied from each peer, including ourselves).
Implementations§
Source§impl OpLog
impl OpLog
pub fn new() -> Self
pub fn next_seq(&self, node: &NodeId) -> u64
pub fn cursor(&self, node: &NodeId) -> u64
pub fn cursors(&self) -> HashMap<NodeId, u64>
pub fn set_cursor(&mut self, node: &NodeId, last_seq: u64)
Sourcepub fn cursor_for(&self, node: &NodeId, typ: &str) -> u64
pub fn cursor_for(&self, node: &NodeId, typ: &str) -> u64
How far this log holds every op of typ from node: the explicit
per-type cursor, or the contiguous prefix of node’s entries (all
types), whichever is further. A pull of one type resumes from here.
pub fn set_cursor_for(&mut self, node: &NodeId, typ: &str, last_seq: u64)
Sourcepub fn type_cursors(&self) -> HashMap<(NodeId, String), u64>
pub fn type_cursors(&self) -> HashMap<(NodeId, String), u64>
Per-type cursors, for an application to persist next to OpLog::cursors.
Sourcepub fn contiguous(&self, node: &NodeId) -> u64
pub fn contiguous(&self, node: &NodeId) -> u64
Highest k such that every seq 1..=k of node is held.
Sourcepub fn newest_hlc(&self) -> Option<&Hlc>
pub fn newest_hlc(&self) -> Option<&Hlc>
The newest HLC held from any node.
Sourcepub fn page_of_type(
&self,
node: &NodeId,
typ: &str,
after_seq: u64,
known_to: u64,
limit: usize,
) -> Page
pub fn page_of_type( &self, node: &NodeId, typ: &str, after_seq: u64, known_to: u64, limit: usize, ) -> Page
Ops of typ from node with after_seq < seq <= known_to, up to limit ops and
PAGE_BUDGET bytes. Missing seqs in that range are other types and are skipped, so
known_to must be OpLog::cursor_for (or less). to_seq is the last seq walked,
which may be past the last op returned; a puller resumes after it.
Sourcepub fn append(
&mut self,
node: NodeId,
hlc: Hlc,
typ: impl Into<String>,
record_id: impl Into<String>,
op: Vec<u8>,
) -> &LogEntry
pub fn append( &mut self, node: NodeId, hlc: Hlc, typ: impl Into<String>, record_id: impl Into<String>, op: Vec<u8>, ) -> &LogEntry
Append a local mutation. seq is assigned here.
Sourcepub fn append_value(
&mut self,
node: NodeId,
hlc: Hlc,
typ: impl Into<String>,
record_id: impl Into<String>,
op: Vec<u8>,
value: Value,
) -> &LogEntry
pub fn append_value( &mut self, node: NodeId, hlc: Hlc, typ: impl Into<String>, record_id: impl Into<String>, op: Vec<u8>, value: Value, ) -> &LogEntry
Append a local entry with a Value (see crate::SyncState::write).
Sourcepub fn chunk(&self, ctyp: &str, hash: &[u8]) -> Option<&[u8]>
pub fn chunk(&self, ctyp: &str, hash: &[u8]) -> Option<&[u8]>
The bytes of chunk hash of chunk type ctyp, from any entry whose bytes hash to it.
Sourcepub fn has_own_chunk(&self, node: &NodeId, ctyp: &str, hash: &[u8]) -> bool
pub fn has_own_chunk(&self, node: &NodeId, ctyp: &str, hash: &[u8]) -> bool
Whether node already wrote chunk hash of ctyp (local writes reuse it).
Sourcepub fn pending_blobs(&self, typ: &str) -> Vec<&LogEntry>
pub fn pending_blobs(&self, typ: &str) -> Vec<&LogEntry>
Entries of typ whose chunked value is not complete yet.
pub fn get(&self, node: &NodeId, seq: u64) -> Option<&LogEntry>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn page(&self, node: &NodeId, after_seq: u64, limit: usize) -> Page
pub fn page(&self, node: &NodeId, after_seq: u64, limit: usize) -> Page
Entries of node with seq > after_seq, up to limit and PAGE_BUDGET plaintext bytes.
Sourcepub fn integrate(&mut self, page: &Page) -> usize
pub fn integrate(&mut self, page: &Page) -> usize
Integrate a remote page. Existing entries of that node are left untouched; gaps are accepted and later pages fill them. Returns how many new entries were stored.
pub fn iter_node(&self, node: &NodeId) -> impl Iterator<Item = &LogEntry>
Trait Implementations§
Auto Trait Implementations§
impl Forget for OpLog
impl Freeze for OpLogwhere
*const LeafNode<(String, u64), LogEntry> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<((String, u64), LogEntry)>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(String, u64)>: Freeze,
PhantomData<((String, String), u64)>: Freeze,
PhantomData<((String, String), Vec<(String, u64)>)>: Freeze,
PhantomData<(String, BTreeSet<(String, u64)>)>: Freeze,
impl Move for OpLog
impl RefUnwindSafe for OpLog
impl Send for OpLog
impl Sync for OpLog
impl Unpin for OpLog
impl UnsafeUnpin for OpLogwhere
*const LeafNode<(String, u64), LogEntry> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<((String, u64), LogEntry)>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, u64)>: UnsafeUnpin,
PhantomData<((String, String), u64)>: UnsafeUnpin,
PhantomData<((String, String), Vec<(String, u64)>)>: UnsafeUnpin,
PhantomData<(String, BTreeSet<(String, u64)>)>: UnsafeUnpin,
impl UnwindSafe for OpLog
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> 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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.