pub struct LogPosition {
pub prev_term: Term,
pub index: LogIndex,
}Expand description
ログの特定位置を識別するためのデータ構造.
Fields§
§prev_term: Term一つ前のインデックスのエントリのTerm.
index: LogIndexこの位置のインデックス.
Implementations§
Source§impl LogPosition
impl LogPosition
Sourcepub fn is_newer_or_equal_than(&self, other: LogPosition) -> bool
pub fn is_newer_or_equal_than(&self, other: LogPosition) -> bool
selfがログ上で、otherと等しい、あるいは、より後方に位置している場合にtrueが返る.
なおselfとotherが、それぞれ分岐したログ上に位置しており、
前後関係が判断できない場合にはfalseが返される.
§Examples
use raftlog::log::LogPosition;
// `a`の方がインデックスが大きい
let a = LogPosition { prev_term: 10.into(), index: 5.into() };
let b = LogPosition { prev_term: 10.into(), index: 3.into() };
assert!(a.is_newer_or_equal_than(b));
assert!(!b.is_newer_or_equal_than(a));
// `a`の方が`Term`が大きい
let a = LogPosition { prev_term: 20.into(), index: 3.into() };
let b = LogPosition { prev_term: 10.into(), index: 3.into() };
assert!(a.is_newer_or_equal_than(b));
assert!(!b.is_newer_or_equal_than(a));
// `a`の方がインデックスは大きいが、`b`の方が`Term`は大きい
// => 順序が確定できない
let a = LogPosition { prev_term: 5.into(), index: 10.into() };
let b = LogPosition { prev_term: 10.into(), index: 3.into() };
assert!(!a.is_newer_or_equal_than(b));
assert!(!b.is_newer_or_equal_than(a));Trait Implementations§
Source§impl Clone for LogPosition
impl Clone for LogPosition
Source§fn clone(&self) -> LogPosition
fn clone(&self) -> LogPosition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LogPosition
impl Debug for LogPosition
Source§impl Default for LogPosition
impl Default for LogPosition
Source§fn default() -> LogPosition
fn default() -> LogPosition
Returns the “default value” for a type. Read more
Source§impl Hash for LogPosition
impl Hash for LogPosition
Source§impl PartialEq for LogPosition
impl PartialEq for LogPosition
impl Copy for LogPosition
impl Eq for LogPosition
impl StructuralPartialEq for LogPosition
Auto Trait Implementations§
impl Freeze for LogPosition
impl RefUnwindSafe for LogPosition
impl Send for LogPosition
impl Sync for LogPosition
impl Unpin for LogPosition
impl UnsafeUnpin for LogPosition
impl UnwindSafe for LogPosition
Blanket Implementations§
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
Mutably borrows from an owned value. Read more