logos-execution-zone/lee/state_machine/src/encoding/privacy_preserving_transaction.rs

26 lines
674 B
Rust
Raw Normal View History

use crate::{
PrivacyPreservingTransaction, error::LeeError, privacy_preserving_transaction::message::Message,
};
2025-08-18 14:28:26 -03:00
impl Message {
2026-03-03 23:21:08 +03:00
#[must_use]
2025-09-02 11:06:41 +03:00
pub fn to_bytes(&self) -> Vec<u8> {
2025-11-25 09:40:46 +02:00
borsh::to_vec(&self).expect("Autoderived borsh serialization failure")
2025-09-02 11:06:41 +03:00
}
pub fn from_bytes(bytes: &[u8]) -> Result<Self, LeeError> {
2025-11-19 09:00:32 +02:00
Ok(borsh::from_slice(bytes)?)
2025-09-02 11:06:41 +03:00
}
}
2025-09-12 15:06:49 +03:00
impl PrivacyPreservingTransaction {
2026-03-03 23:21:08 +03:00
#[must_use]
2025-09-12 15:06:49 +03:00
pub fn to_bytes(&self) -> Vec<u8> {
2025-11-25 09:40:46 +02:00
borsh::to_vec(&self).expect("Autoderived borsh serialization failure")
2025-09-12 15:06:49 +03:00
}
pub fn from_bytes(bytes: &[u8]) -> Result<Self, LeeError> {
Ok(borsh::from_slice(bytes)?)
2025-09-12 15:06:49 +03:00
}
}