Struct ShardIdent

Source
pub struct ShardIdent { /* private fields */ }
Expand description

Shard ident.

Implementations§

Source§

impl ShardIdent

Source

pub const PREFIX_FULL: u64 = 9_223_372_036_854_775_808u64

The prefix for the full shard.

Source

pub const MAX_SPLIT_DEPTH: u8 = 60u8

Max possible shard split depth.

Source

pub const BITS: u16 = 104u16

The number of data bits that this struct occupies.

Source

pub const MASTERCHAIN: Self

Masterchain shard ident.

Source

pub const BASECHAIN: Self

Base workchain shard ident.

Source

pub const fn new(workchain: i32, prefix: u64) -> Option<Self>

Tries to create a new shard ident from parts.

Source

pub const fn new_full(workchain: i32) -> Self

Creates a new full shard ident for the specified workchain.

Source

pub const unsafe fn new_unchecked(workchain: i32, prefix: u64) -> Self

Creates a new shard ident from parts.

§Safety

The following must be true:

  • prefix must not be zero.
  • low bits must not be used (see MAX_SPLIT_DEPTH).
Source

pub const fn workchain(&self) -> i32

Returns the shard workchain.

Source

pub const fn prefix(&self) -> u64

Returns the shard prefix.

Source

pub const fn is_masterchain(&self) -> bool

Returns true if this shard is a masterchain shard.

See MASTERCHAIN

Source

pub const fn is_full(&self) -> bool

Returns true if this shard could not be merged further.

See PREFIX_FULL

Source

pub const fn is_left_child(&self) -> bool

Returns true if this shard is the left child of the parent shard.

NOTE: Full shard is left.

Source

pub const fn is_right_child(&self) -> bool

Returns true if this shard is the right child of the parent shard.

NOTE: Full shard is left.

Source

pub const fn is_ancestor_of(&self, shard: &Self) -> bool

Returns true if the current shard is somewhere in the parents hierarchy of the specified shard.

Source

pub const fn is_parent_of(&self, child: &Self) -> bool

Returns true if the current shard is the direct parent of the specified shard.

Source

pub const fn is_child_of(&self, parent: &Self) -> bool

Returns true if the current shard is the direct child of the specified shard.

Source

pub const fn intersects(&self, other: &Self) -> bool

Returns true if one shard fully includes another.

Source

pub const fn merge(&self) -> Option<Self>

Returns the parent shard of the current shard.

Returns None for the full shard.

Source

pub const fn split(&self) -> Option<(Self, Self)>

Splits the current shard into two children.

Returns None for the shard with depth > MAX_SPLIT_DEPTH.

Source

pub const fn opposite(&self) -> Option<Self>

Returns the opposite shard if appliable.

Returns None for the shard with depth == 0.

Source

pub const fn prefix_len(&self) -> u16

Returns shard prefix len in bits.

Source

pub const fn can_split(&self) -> bool

Returns whether the shard depth is in the possible range.

Source

pub fn contains_address<T: Addr>(&self, address: &T) -> bool

Returns true if the specified address could be stored in the current shard.

Source

pub const fn contains_account(&self, account: &HashBytes) -> bool

Returns true if the specified account could be stored in the current shard.

Trait Implementations§

Source§

impl Clone for ShardIdent

Source§

fn clone(&self) -> ShardIdent

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShardIdent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ShardIdent

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ShardIdent

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ShardIdent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ShardIdent> for ShardIdentFull

Source§

fn from(ident: ShardIdent) -> Self

Converts to this type from the input type.
Source§

impl FromStr for ShardIdent

Source§

type Err = ParseBlockIdError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for ShardIdent

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> Load<'a> for ShardIdent

Source§

fn load_from(slice: &mut CellSlice<'a>) -> Result<Self, Error>

Tries to load itself from a cell slice.
Source§

impl Ord for ShardIdent

Source§

fn cmp(&self, other: &ShardIdent) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ShardIdent

Source§

fn eq(&self, other: &ShardIdent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ShardIdent

Source§

fn partial_cmp(&self, other: &ShardIdent) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for ShardIdent

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Store for ShardIdent

Source§

fn store_into( &self, builder: &mut CellBuilder, _: &dyn CellContext, ) -> Result<(), Error>

Tries to store itself into the cell builder.
Source§

impl TryFrom<ShardIdentFull> for ShardIdent

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(ident: ShardIdentFull) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for ShardIdent

Source§

impl Eq for ShardIdent

Source§

impl StructuralPartialEq for ShardIdent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compares self to key and returns their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compares self to key and returns true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> EquivalentRepr<T> for T