parst/
lib.rs

1#![feature(split_array)]
2#![feature(array_try_from_fn)]
3
4#[cfg(feature = "endian")]
5pub mod endian;
6pub mod error;
7
8pub(crate) mod helpers;
9
10mod collections;
11mod primitives;
12
13use std::io::Write;
14
15#[cfg(feature = "derive")]
16pub use parst_derive::{Deparsable, Parsable};
17
18pub type PResult<'a, O, S, E = crate::error::Error> = std::result::Result<(O, &'a S), E>;
19pub type PResultBytes<'a, O> = PResult<'a, O, [u8]>;
20pub type PResultStr<'a, O> = PResult<'a, O, str>;
21
22pub trait Parsable<'a, Src, Ctx = ()>: Sized
23where
24	Src: ?Sized,
25{
26	fn read(source: &'a Src, context: Ctx) -> PResult<Self, Src>;
27}
28
29pub trait Deparsable {
30	fn write(&self, w: &mut impl Write) -> std::io::Result<()>;
31}