blob: 0a03fe43c3d2f1179dfa034f5629ba6ae26d2b37 [file] [log] [blame]
// @generated rust packets from foo.pdl
use bytes::{BufMut, Bytes, BytesMut};
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive};
use std::convert::{TryFrom, TryInto};
use std::fmt;
use std::sync::Arc;
use thiserror::Error;
type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("Packet parsing failed")]
InvalidPacketError,
#[error("{field} was {value:x}, which is not known")]
ConstraintOutOfBounds { field: String, value: u64 },
#[error("when parsing {obj}.{field} needed length of {wanted} but got {got}")]
InvalidLengthError { obj: String, field: String, wanted: usize, got: usize },
#[error("Due to size restrictions a struct could not be parsed.")]
ImpossibleStructError,
#[error("when parsing field {obj}.{field}, {value} is not a valid {type_} value")]
InvalidEnumValueError { obj: String, field: String, value: u64, type_: String },
}
#[derive(Debug, Error)]
#[error("{0}")]
pub struct TryFromError(&'static str);
pub trait Packet {
fn to_bytes(self) -> Bytes;
fn to_vec(self) -> Vec<u8>;
}