29 lines
707 B
Rust
29 lines
707 B
Rust
use rkyv::Deserialize;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct TxConfig {
|
|
pub len: u64,
|
|
pub mtu: u16,
|
|
pub description: String,
|
|
}
|
|
|
|
impl From<cuttle::TxConfig> for TxConfig {
|
|
fn from(value: cuttle::TxConfig) -> Self {
|
|
TxConfig {
|
|
len: value.len,
|
|
mtu: value.mtu,
|
|
description: value.description,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn get_tx_config(bytes: Vec<u8>) -> Option<TxConfig> {
|
|
if let Ok(archive) = rkyv::check_archived_root::<cuttle::TxConfig>(&bytes) {
|
|
if let Ok::<cuttle::TxConfig, _>(conf) = archive.deserialize(&mut rkyv::Infallible) {
|
|
return Some(conf.into());
|
|
} else {
|
|
return None;
|
|
}
|
|
}
|
|
None
|
|
}
|