Struct ibc::ics24_host::identifier::ChainId[][src]

pub struct ChainId { /* fields omitted */ }
Expand description

This type is subject to future changes.

TODO: ChainId validation is not standardized yet. is_epoch_format will most likely be replaced by validate_chain_id()-style function. See: https://github.com/informalsystems/ibc-rs/pull/304#discussion_r503917283.

Also, contrast with tendermint-rs ChainId type.

Implementations

Creates a new ChainId given a chain name and an epoch number.

The returned ChainId will have the format: {chain name}-{epoch number}.

use ibc::ics24_host::identifier::ChainId;

let epoch_number = 10;
let id = ChainId::new("chainA".to_string(), epoch_number);
assert_eq!(id.version(), epoch_number);

Get a reference to the underlying string.

Extract the version from this chain identifier.

Extract the version from the given chain identifier.

use ibc::ics24_host::identifier::ChainId;

assert_eq!(ChainId::chain_version("chain--a-0"), 0);
assert_eq!(ChainId::chain_version("ibc-10"), 10);
assert_eq!(ChainId::chain_version("cosmos-hub-97"), 97);
assert_eq!(ChainId::chain_version("testnet-helloworld-2"), 2);

is_epoch_format() checks if a chain_id is in the format required for parsing epochs The chainID must be in the form: {chainID}-{version}

use ibc::ics24_host::identifier::ChainId;
assert_eq!(ChainId::is_epoch_format("chainA-0"), false);
assert_eq!(ChainId::is_epoch_format("chainA"), false);
assert_eq!(ChainId::is_epoch_format("chainA-1"), true);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

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

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Wrap the input message T in a tonic::Request

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more