Skip to content

from_bytes not working for passing a ctx #493

Discussion options

You must be logged in to vote

When using ctx as the entry point, you need to use from_reader_with_ctx:

pub fn deserialization(packet: &[u8]) {
    let data_length: u8 = 10;
    let mut binding = Cursor::new(packet);
    let mut reader = Reader::new(&mut binding);
    match EthernetFrame::from_reader_with_ctx(&mut reader, data_length) {
        Ok(frame_value) => {
            println!("packet de-serialized: {:?}", frame_value);
        }
        Err(e) => eprintln!("Error in deserialization: {:?}", e),
    }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by soumyasen1809
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #492 on October 25, 2024 02:30.