mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-29 09:57:46 +00:00
31 lines
820 B
Rust
31 lines
820 B
Rust
|
use binrw::{BinRead, BinWrite, binrw};
|
||
|
|
||
|
pub trait IpcSegmentTrait:
|
||
|
for<'a> BinRead<Args<'a> = ()> + for<'a> BinWrite<Args<'a> = ()> + std::fmt::Debug + 'static
|
||
|
{
|
||
|
fn calc_size(&self) -> u32;
|
||
|
}
|
||
|
|
||
|
#[binrw]
|
||
|
#[derive(Debug, Clone)]
|
||
|
pub struct IpcSegment<OpCode, Data>
|
||
|
where
|
||
|
for<'a> OpCode: BinRead<Args<'a> = ()> + 'a + std::fmt::Debug,
|
||
|
for<'a> OpCode: BinWrite<Args<'a> = ()> + 'a + std::fmt::Debug,
|
||
|
for<'a> Data: BinRead<Args<'a> = (&'a OpCode,)> + 'a + std::fmt::Debug,
|
||
|
for<'a> Data: BinWrite<Args<'a> = ()> + 'a + std::fmt::Debug,
|
||
|
{
|
||
|
pub unk1: u8,
|
||
|
pub unk2: u8,
|
||
|
#[br(dbg)]
|
||
|
pub op_code: OpCode,
|
||
|
#[brw(pad_before = 2)] // empty
|
||
|
#[br(dbg)]
|
||
|
pub server_id: u16,
|
||
|
#[br(dbg)]
|
||
|
pub timestamp: u32,
|
||
|
#[brw(pad_before = 4)]
|
||
|
#[br(args(&op_code))]
|
||
|
pub data: Data,
|
||
|
}
|