[][src]Struct raftlog::log::LogPosition

pub struct LogPosition {
    pub prev_term: Term,
    pub index: LogIndex,
}

ログの特定位置を識別するためのデータ構造.

Fields

prev_term: Term

一つ前のインデックスのエントリのTerm.

index: LogIndex

この位置のインデックス.

Methods

impl LogPosition[src]

pub fn is_newer_or_equal_than(&self, other: LogPosition) -> bool[src]

selfがログ上で、otherと等しい、あるいは、より後方に位置している場合にtrueが返る.

なおselfotherが、それぞれ分岐したログ上に位置しており、 前後関係が判断できない場合には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

impl Clone for LogPosition[src]

impl Copy for LogPosition[src]

impl Debug for LogPosition[src]

impl Default for LogPosition[src]

impl Eq for LogPosition[src]

impl Hash for LogPosition[src]

impl PartialEq<LogPosition> for LogPosition[src]

impl StructuralEq for LogPosition[src]

impl StructuralPartialEq for LogPosition[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.