serialize UserAccount

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-03-17 19:23:50 -04:00
parent ad90a9565a
commit d9f92ef54f

View File

@@ -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);
}
}