| 0.1.0 |  | 
|---|
#200 in #cosmos
在  2 crates 中使用
5KB
55 代码行
类型包
类型包包含所有由 模块 和 包 使用的通用类型。
类型
Msg
消息类型是已从 protobuf 编码的交易消息的表示。它是 Any 类型的包装,可以与之相互转换。
pub struct Msg(pub Any);
/// From protobuf definition
pub struct Any {
    pub type_url: String,
    pub value: Vec<u8>,
}
fn example() {
    let proto_msg = Msg(Any {
        type_url: "/cosmos.bank.v1beta1.Msg/Send".to_string(),
        value: msg_bytes,
    });
}
Error
Error 是表示在钱包操作执行过程中可能发生的任何类型错误的表示。
任何返回 Result<T,E> 的函数都可以按如下方式返回错误给上述函数
fn example() {
    let mnemonic = Mnemonic::from_phrase(mnemonic_words, Language::English)
    .map_err(|err| Error::Mnemonic(err.to_string()))?;
}
依赖项
~3MB
~68K SLoC