[−][src]Struct frugalos_raft::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]
pub fn clone(&self) -> LocalNodeId
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for LocalNodeId
[src]
impl Debug for LocalNodeId
[src]
impl<'de> Deserialize<'de> for LocalNodeId
[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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.
pub fn from_str(s: &str) -> Result<Self>
[src]
impl Hash for LocalNodeId
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for LocalNodeId
[src]
pub fn cmp(&self, other: &LocalNodeId) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<LocalNodeId> for LocalNodeId
[src]
pub fn eq(&self, other: &LocalNodeId) -> bool
[src]
pub fn ne(&self, other: &LocalNodeId) -> bool
[src]
impl PartialOrd<LocalNodeId> for LocalNodeId
[src]
pub fn partial_cmp(&self, other: &LocalNodeId) -> Option<Ordering>
[src]
pub fn lt(&self, other: &LocalNodeId) -> bool
[src]
pub fn le(&self, other: &LocalNodeId) -> bool
[src]
pub fn gt(&self, other: &LocalNodeId) -> bool
[src]
pub fn ge(&self, other: &LocalNodeId) -> bool
[src]
impl Serialize for LocalNodeId
[src]
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for LocalNodeId
[src]
impl StructuralPartialEq for LocalNodeId
[src]
Auto Trait Implementations
impl RefUnwindSafe for LocalNodeId
impl Send for LocalNodeId
impl Sync for LocalNodeId
impl Unpin for LocalNodeId
impl UnwindSafe for LocalNodeId
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,