pub struct TrustThreshold {
    pub numerator: u64,
    pub denominator: u64,
}
Expand description

Defines the level of trust that a client has towards a set of validators of a chain.

A trust threshold is represented as a fraction, i.e., a numerator and and a denominator. A typical trust threshold is 1/3 in practice. This type accepts even a value of 0, (numerator = 0, denominator = 0), which is used in the client state of an upgrading client.

Fields§

§numerator: u64§denominator: u64

Implementations§

source§

impl TrustThreshold

source

pub const ONE_THIRD: Self = _

Constant for a trust threshold of 1/3.

source

pub const TWO_THIRDS: Self = _

Constant for a trust threshold of 2/3.

source

pub const ZERO: Self = _

Constant for a trust threshold of 0/0.

source

pub fn new(numerator: u64, denominator: u64) -> Result<Self, Error>

Instantiate a TrustThreshold with the given denominator and numerator.

The constructor succeeds if long as the resulting fraction is in the range[0, 1).

source

pub fn numerator(&self) -> u64

The numerator of the fraction underlying this trust threshold.

source

pub fn denominator(&self) -> u64

The denominator of the fraction underlying this trust threshold.

Trait Implementations§

source§

impl Clone for TrustThreshold

source§

fn clone(&self) -> TrustThreshold

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for TrustThreshold

source§

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

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

impl Default for TrustThreshold

source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for TrustThreshold

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 TrustThreshold

source§

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

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

impl From<TrustThreshold> for Fraction

source§

fn from(t: TrustThreshold) -> Self

Converts to this type from the input type.
source§

impl From<TrustThresholdFraction> for TrustThreshold

Conversion from Tendermint domain type into IBC domain type.

source§

fn from(t: TrustThresholdFraction) -> Self

Converts to this type from the input type.
source§

impl PartialEq for TrustThreshold

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Protobuf<Fraction> for TrustThreshold

source§

fn encode<B>(self, buf: &mut B) -> Result<(), Error>
where B: BufMut,

Encode into a buffer in Protobuf format. Read more
source§

fn encode_length_delimited<B>(self, buf: &mut B) -> Result<(), Error>
where B: BufMut,

Encode with a length-delimiter to a buffer in Protobuf format. Read more
source§

fn decode<B>(buf: B) -> Result<Self, Error>
where B: Buf,

Constructor that attempts to decode an instance from a buffer. Read more
source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, Error>
where B: Buf,

Constructor that attempts to decode a length-delimited instance from the buffer. Read more
source§

fn encoded_len(self) -> usize

Returns the encoded length of the message without a length delimiter. Read more
source§

fn encode_vec(self) -> Vec<u8>

Encodes into a Protobuf-encoded Vec<u8>.
source§

fn decode_vec(v: &[u8]) -> Result<Self, Error>

Constructor that attempts to decode a Protobuf-encoded instance from a Vec<u8> (or equivalent).
source§

fn encode_length_delimited_vec(self) -> Vec<u8>

Encode with a length-delimiter to a Vec<u8> Protobuf-encoded message.
source§

fn decode_length_delimited_vec(v: &[u8]) -> Result<Self, Error>

Constructor that attempts to decode a Protobuf-encoded instance with a length-delimiter from a Vec<u8> or equivalent.
source§

impl Serialize for TrustThreshold

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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

impl TryFrom<Fraction> for TrustThreshold

§

type Error = Error

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

fn try_from(value: Fraction) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<TrustThreshold> for TrustThresholdFraction

Conversion from IBC domain type into Tendermint domain type.

§

type Error = Error

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

fn try_from(t: TrustThreshold) -> Result<TrustThresholdFraction, Self::Error>

Performs the conversion.
source§

impl Copy for TrustThreshold

source§

impl Eq for TrustThreshold

source§

impl StructuralPartialEq for TrustThreshold

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> 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

§

type Output = T

Should always be Self
source§

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

§

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§

default 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>,

§

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>,

§

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>,