Skip to content
Snippets Groups Projects
Commit 1d25738d authored by nanocryk's avatar nanocryk Committed by Éloïs
Browse files

Document trait is now generic over the currency code data type (v10/v11...

Document trait is now generic over the currency code data type (v10/v11 compatible) [test,fmt,clippy]
parent 07cbcaad
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ pub struct IdentityDocument {
impl Document for IdentityDocument {
type PublicKey = ed25519::PublicKey;
type CurrencyType = str;
fn version(&self) -> u16 {
10
......
......@@ -64,7 +64,8 @@ pub enum V10Document {
}
/// Trait for a V10 document.
pub trait TextDocument: Document<PublicKey = ed25519::PublicKey> {
pub trait TextDocument
: Document<PublicKey = ed25519::PublicKey, CurrencyType = str> {
/// Return document as text.
fn as_text(&self) -> &str;
......
......@@ -39,12 +39,14 @@ pub enum BlockchainProtocol {
pub trait Document: Debug {
/// Type of the `PublicKey` used by the document.
type PublicKey: PublicKey;
/// Data type of the currency code used by the document.
type CurrencyType: ?Sized;
/// Get document version.
fn version(&self) -> u16;
/// Get document currency.
fn currency(&self) -> &str;
fn currency(&self) -> &Self::CurrencyType;
/// Iterate over document issuers.
fn issuers(&self) -> &Vec<Self::PublicKey>;
......@@ -148,6 +150,7 @@ mod tests {
impl Document for PlainTextDocument {
type PublicKey = ed25519::PublicKey;
type CurrencyType = str;
fn version(&self) -> u16 {
unimplemented!()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment