[][src]Struct frugalos_raft::LocalNodeId

pub struct LocalNodeId(_);

Serviceローカルな7バイト長のID.

このIDは、一つのService内で一意である必要がある.

また、複数ノードが同じDeviceHandleを共有する場合には、 それぞれのIDは異なるものである必要がある (これが守られない場合には、名前空間が衝突し、データが破損してしまう危険性がある).

Examples

16進文字列との相互変換.

use frugalos_raft::LocalNodeId;

let id = LocalNodeId::new([0, 11, 222, 3, 44, 5, 66]);
assert_eq!(id.to_string(), "bde032c0542");
assert_eq!("bde032c0542".parse::<LocalNodeId>().unwrap(), id);

Implementations

impl LocalNodeId[src]

pub fn new(id: [u8; 7]) -> Self[src]

新しいLocalNodeIdインスタンスを生成する.

pub fn as_slice(&self) -> &[u8][src]

IDをスライス形式に変換して返す.

pub fn to_ballot_lump_id(self) -> LumpId[src]

Ballot用のLumpIdを返す.

LumpIdのレイアウト (Erlang表記)

<<LocalNodeId:56, (Type=0):8, 0:64>>

Examples

This example is not tested
use frugalos_raft::LocalNodeId;

assert_eq!(LocalNodeId::new([1; 7]).to_ballot_lump_id().as_ref(),
           [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]);

pub fn to_log_entry_lump_id(self, index: LogIndex) -> LumpId[src]

指定されたインデックスのログエントリ用のLumpIdを返す.

LumpIdのレイアウト (Erlang表記)

<<LocalNodeId:56, (Type=1):8, Index:64>>

Examples

This example is not tested
use frugalos_raft::LocalNodeId;

assert_eq!(LocalNodeId::new([2; 7]).to_log_entry_lump_id(3.into()).as_ref(),
           [2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 3]);

pub fn to_log_prefix_index_lump_id(self) -> LumpId[src]

LogPrefixの格納場所を保持するためのLumpIdを返す.

LumpIdのレイアウト (Erlang表記)

<<LocalNodeId:56, (Type=2):8, 0:64>>

Examples

This example is not tested
use frugalos_raft::LocalNodeId;

assert_eq!(LocalNodeId::new([1; 7]).to_log_prefix_index_lump_id().as_ref(),
           [1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0]);

pub fn to_log_prefix_lump_id(self, index: u64) -> LumpId[src]

指定された位置に保存されるLogPrefix用のLumpIdを返す.

LumpIdのレイアウト (Erlang表記)

<<LocalNodeId:56, (Type=3):8, Index:64>>

Examples

This example is not tested
use frugalos_raft::LocalNodeId;

assert_eq!(LocalNodeId::new([1; 7]).to_log_prefix_lump_id(4).as_ref(),
           [1, 1, 1, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 4]);

pub fn to_available_lump_id_range(self) -> Range<LumpId>[src]

このノードが取り得る LumpId の範囲を返す.

Examples

use frugalos_raft::LocalNodeId;

let mut id = [0; 7];
id[6] = 1;
let range = LocalNodeId::new(id).to_available_lump_id_range();
assert_eq!(range.start.as_u128(), 4722366482869645213696);
assert_eq!(range.end.as_u128(), 9444732965739290427392);
assert_eq!(range.end.as_u128() / range.start.as_u128(), 2);

Trait Implementations

impl Clone for LocalNodeId[src]

impl Copy for LocalNodeId[src]

impl Debug for LocalNodeId[src]

impl<'de> Deserialize<'de> for LocalNodeId[src]

impl Display for LocalNodeId[src]

impl Eq for LocalNodeId[src]

impl FromStr for LocalNodeId[src]

type Err = Error

The associated error which can be returned from parsing.

impl Hash for LocalNodeId[src]

impl Ord for LocalNodeId[src]

impl PartialEq<LocalNodeId> for LocalNodeId[src]

impl PartialOrd<LocalNodeId> for LocalNodeId[src]

impl Serialize for LocalNodeId[src]

impl StructuralEq for LocalNodeId[src]

impl StructuralPartialEq for LocalNodeId[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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

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

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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.