mod packet;
pub use packet::{
Packet, ReadByteExt, ReadPacket, Report, ReportField, WriteByteExt, WritePacket, MARK_BYTE,
SYNC_BYTE,
};
#[cfg(feature = "jvs")]
pub mod jvs;
#[cfg(feature = "jvs_modified")]
pub mod jvs_modified;
#[cfg(any(feature = "jvs", feature = "jvs_modified"))]
macro_rules! impl_required_packet_blocks {
($t:tt) => {
impl<const N: usize> $t<N> {
pub const fn new() -> Self {
Self { inner: [0; N] }
}
pub fn from_reader(reader: &mut impl crate::ReadPacket) -> std::io::Result<Self> {
let mut packet = $t::new();
reader.read_packet(&mut packet)?;
Ok(packet)
}
pub fn from_slice(slice: &[u8]) -> Self {
let mut packet = Self::new();
packet.inner[..slice.len()].copy_from_slice(slice);
packet
}
}
impl<const N: usize> AsRef<[u8]> for $t<N> {
fn as_ref(&self) -> &[u8] {
&self.inner
}
}
impl<const N: usize> AsMut<[u8]> for $t<N> {
fn as_mut(&mut self) -> &mut [u8] {
&mut self.inner
}
}
impl<const N: usize> Default for $t<N> {
fn default() -> Self {
Self::new()
}
}
};
}
pub(crate) use impl_required_packet_blocks;