Skip to main content

dvi/
traits.rs

1use nom::IResult;
2use std::io::{self, Write};
3
4/// A type that can be written to a stream (serialized)
5pub trait Dump {
6    fn dump<W>(&self, _: &mut W) -> io::Result<()>
7    where
8        W: Write;
9}
10
11/// A type that can be parsed from a byte slice
12pub trait Parse<V>
13where
14    V: AsRef<[u8]>,
15    Self: Sized,
16{
17    /// Returns the Instruction and how many bytes were used
18    fn parse(v: V) -> IResult<V, Self>;
19}