iota_model/
signature.rs

1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4use serde_json;
5
6/// Represents an address and a grouping of signature fragments
7#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
8pub struct Signature {
9    /// Transaction address
10    pub address: String,
11    /// A signature or a message, both of which may be fragmented over multiple transactions in the bundle.
12    pub signature_fragments: Vec<String>,
13}
14
15impl fmt::Display for Signature {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        write!(
18            f,
19            "{}",
20            serde_json::to_string_pretty(self).unwrap_or_default()
21        )
22    }
23}
24
25impl Signature {
26    /// Inserts a fragment into the signature
27    pub fn add_fragment(&mut self, fragment: impl Into<String>) {
28        self.signature_fragments.push(fragment.into());
29    }
30}