commit d9f92ef54fb676fa39a8d35bbf9dc792f63a9423
parent ad90a9565aebd54bd8217170adc2e91d65b6895b
Author: kernelkind <kernelkind@gmail.com>
Date: Mon, 17 Mar 2025 19:23:50 -0400
serialize `UserAccount`
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/crates/notedeck/src/user_account.rs b/crates/notedeck/src/user_account.rs
@@ -1,4 +1,5 @@
use enostr::Keypair;
+use tokenator::TokenSerializable;
pub struct UserAccount {
pub key: Keypair,
@@ -9,3 +10,15 @@ impl UserAccount {
Self { key }
}
}
+
+impl TokenSerializable for UserAccount {
+ fn parse_from_tokens<'a>(
+ parser: &mut tokenator::TokenParser<'a>,
+ ) -> Result<Self, tokenator::ParseError<'a>> {
+ Ok(UserAccount::new(Keypair::parse_from_tokens(parser)?))
+ }
+
+ fn serialize_tokens(&self, writer: &mut tokenator::TokenWriter) {
+ self.key.serialize_tokens(writer);
+ }
+}