waves-rust 0.2.6

A Rust library for interacting with the Waves blockchain. Supports node interaction, offline transaction signing and creating addresses and keys.
Documentation
use crate::error::Result;
use crate::model::ByteString;
use crate::util::Base58;
use std::fmt;

#[derive(Clone, Eq, PartialEq, Hash)]
pub struct Id {
    bytes: Vec<u8>,
}

impl fmt::Debug for Id {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "Id {{ {} }}", self.encoded())
    }
}

impl Id {
    pub fn from_string(id: &str) -> Result<Id> {
        Ok(Id {
            bytes: Base58::decode(id)?,
        })
    }

    pub fn from_bytes(id: &[u8]) -> Id {
        Id { bytes: id.into() }
    }
}

impl ByteString for Id {
    fn bytes(&self) -> Vec<u8> {
        self.bytes.clone()
    }

    fn encoded(&self) -> String {
        Base58::encode(&self.bytes, false)
    }

    fn encoded_with_prefix(&self) -> String {
        Base58::encode(&self.bytes, true)
    }
}