rust implementation, fast enough it looks

This commit is contained in:
devdesk
2024-02-15 23:24:22 +02:00
parent d661bf27ae
commit acf9b2c4c4
3 changed files with 525 additions and 9 deletions

View File

@@ -89,7 +89,7 @@ impl PacketsIterator {
pub struct Header {
c1: u32,
c2: u16,
part: u16,
pub part: u16,
a: u16,
ffaa: u16,
b: u16,
@@ -98,7 +98,7 @@ pub struct Header {
}
impl Header {
fn read(data: &[u8]) -> anyhow::Result<Self> {
pub fn read(data: &[u8]) -> anyhow::Result<Self> {
Ok(Header {
c1: u32::from_be_bytes([data[0], data[1], data[2], data[3]]),
c2: u16::from_be_bytes([data[4], data[5]]),
@@ -122,12 +122,12 @@ impl Header {
}
}
const HDR_SIZE: usize = std::mem::size_of::<Header>();
pub const HDR_SIZE: usize = std::mem::size_of::<Header>();
pub struct Frame {
#[allow(dead_code)]
header: Header,
raw: Vec<u8>,
pub header: Header,
pub raw: Vec<u8>,
}
impl Frame {
@@ -184,7 +184,7 @@ impl Iterator for Decoder {
}
}
fn write_raw_frame(name: &str, data: &[u8]) -> anyhow::Result<()> {
pub fn write_raw_frame(name: &str, data: &[u8]) -> anyhow::Result<()> {
let path = Path::new(&name);
let file = File::create(path)?;
let ref mut w = BufWriter::new(file);