pub struct TrustThreshold { /* private fields */ }
Expand description
TrustThreshold
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 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.
Implementations§
Source§impl TrustThreshold
impl TrustThreshold
Sourcepub const ONE_THIRD: TrustThreshold
pub const ONE_THIRD: TrustThreshold
Constant for a trust threshold of 1/3.
Sourcepub const TWO_THIRDS: TrustThreshold
pub const TWO_THIRDS: TrustThreshold
Constant for a trust threshold of 2/3.
Sourcepub const ZERO: TrustThreshold
pub const ZERO: TrustThreshold
Constant for a trust threshold of 0/0.
Sourcepub fn new(
numerator: u64,
denominator: u64,
) -> Result<TrustThreshold, ClientError>
pub fn new( numerator: u64, denominator: u64, ) -> Result<TrustThreshold, ClientError>
Instantiate a TrustThreshold with the given denominator and numerator.
The constructor succeeds if long as the resulting fraction
is in the range[0, 1)
.
Sourcepub fn denominator(&self) -> u64
pub fn denominator(&self) -> u64
The denominator of the fraction underlying this trust threshold.
Trait Implementations§
Source§impl BorshDeserialize for TrustThreshold
impl BorshDeserialize for TrustThreshold
fn deserialize_reader<__R>(reader: &mut __R) -> Result<TrustThreshold, Error>where
__R: Read,
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for TrustThreshold
impl BorshSerialize for TrustThreshold
Source§impl Clone for TrustThreshold
impl Clone for TrustThreshold
Source§fn clone(&self) -> TrustThreshold
fn clone(&self) -> TrustThreshold
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for TrustThreshold
impl Debug for TrustThreshold
Source§impl Decode for TrustThreshold
impl Decode for TrustThreshold
Source§fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<TrustThreshold, Error>where
__CodecInputEdqy: Input,
fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<TrustThreshold, Error>where
__CodecInputEdqy: Input,
Attempt to deserialise the value from input.
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl<'de> Deserialize<'de> for TrustThreshold
impl<'de> Deserialize<'de> for TrustThreshold
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TrustThreshold, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TrustThreshold, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for TrustThreshold
impl Display for TrustThreshold
Source§impl Encode for TrustThreshold
impl Encode for TrustThreshold
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
Source§fn encode_to<__CodecOutputEdqy>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
Convert self to a slice and append it to the destination.
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl From<TrustThreshold> for Fraction
impl From<TrustThreshold> for Fraction
Source§fn from(t: TrustThreshold) -> Fraction
fn from(t: TrustThreshold) -> Fraction
Converts to this type from the input type.
Source§impl From<TrustThresholdFraction> for TrustThreshold
Conversion from Tendermint domain type into
IBC domain type.
impl From<TrustThresholdFraction> for TrustThreshold
Conversion from Tendermint domain type into IBC domain type.
Source§fn from(t: TrustThresholdFraction) -> TrustThreshold
fn from(t: TrustThresholdFraction) -> TrustThreshold
Converts to this type from the input type.
Source§impl PartialEq for TrustThreshold
impl PartialEq for TrustThreshold
Source§impl Protobuf<Fraction> for TrustThreshold
impl Protobuf<Fraction> for TrustThreshold
Source§fn encode<B>(self, buf: &mut B) -> Result<(), Error>where
B: BufMut,
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,
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,
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,
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
fn encoded_len(self) -> usize
Returns the encoded length of the message without a length delimiter. Read more
Source§fn decode_vec(v: &[u8]) -> Result<Self, Error>
fn decode_vec(v: &[u8]) -> Result<Self, Error>
Constructor that attempts to decode a Protobuf-encoded instance from a
Vec<u8>
(or equivalent).Source§impl Serialize for TrustThreshold
impl Serialize for TrustThreshold
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<Fraction> for TrustThreshold
impl TryFrom<Fraction> for TrustThreshold
Source§type Error = DecodingError
type Error = DecodingError
The type returned in the event of a conversion error.
Source§fn try_from(
value: Fraction,
) -> Result<TrustThreshold, <TrustThreshold as TryFrom<Fraction>>::Error>
fn try_from( value: Fraction, ) -> Result<TrustThreshold, <TrustThreshold as TryFrom<Fraction>>::Error>
Performs the conversion.
Source§impl TypeInfo for TrustThreshold
impl TypeInfo for TrustThreshold
impl Copy for TrustThreshold
impl EncodeLike for TrustThreshold
impl Eq for TrustThreshold
impl StructuralPartialEq for TrustThreshold
Auto Trait Implementations§
impl Freeze for TrustThreshold
impl RefUnwindSafe for TrustThreshold
impl Send for TrustThreshold
impl Sync for TrustThreshold
impl Unpin for TrustThreshold
impl UnwindSafe for TrustThreshold
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more