nym_types/
helpers.rs

1// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use serde::{Deserialize, Serialize};
5use std::fmt::{Display, Formatter};
6
7#[derive(Serialize, Deserialize)]
8pub struct ConsoleSigningOutput {
9    pub encoded_message: String,
10    pub encoded_signature: String,
11}
12
13impl ConsoleSigningOutput {
14    pub fn new(encoded_message: impl Into<String>, encoded_signature: impl Into<String>) -> Self {
15        Self {
16            encoded_message: encoded_message.into(),
17            encoded_signature: encoded_signature.into(),
18        }
19    }
20}
21
22impl Display for ConsoleSigningOutput {
23    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
24        write!(
25            f,
26            "the base58-encoded signature on: '{}' is:\n{}",
27            self.encoded_message, self.encoded_signature
28        )
29    }
30}