mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-04-21 10:53:14 +00:00
Add Identity name
This commit is contained in:
parent
a9ca4ffb7d
commit
705236f85c
@ -3,6 +3,7 @@ use std::fmt;
|
|||||||
use crate::crypto::{PrivateKey, PublicKey};
|
use crate::crypto::{PrivateKey, PublicKey};
|
||||||
|
|
||||||
pub struct Identity {
|
pub struct Identity {
|
||||||
|
name: String,
|
||||||
secret: PrivateKey,
|
secret: PrivateKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,8 +17,9 @@ impl fmt::Debug for Identity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Identity {
|
impl Identity {
|
||||||
pub fn new() -> Self {
|
pub fn new(name: impl Into<String>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
name: name.into(),
|
||||||
secret: PrivateKey::random(),
|
secret: PrivateKey::random(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,10 +31,17 @@ impl Identity {
|
|||||||
pub fn secret(&self) -> &PrivateKey {
|
pub fn secret(&self) -> &PrivateKey {
|
||||||
&self.secret
|
&self.secret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns an associated name for this Identity.
|
||||||
|
// Names are a friendly developer chosen identifier for an Identity which
|
||||||
|
// can provide between logging.
|
||||||
|
pub fn get_name(&self) -> &str {
|
||||||
|
return &self.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Identity {
|
impl Default for Identity {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new("default")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user