mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 20:55:03 +01:00
better parser generation
This commit is contained in:
parent
c43126af1f
commit
83778ac2c9
10 changed files with 859 additions and 516 deletions
|
|
@ -14,10 +14,10 @@ mod frame_type {
|
|||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Frame {
|
||||
/// The type of the frame including its parsed metadata.
|
||||
kind: FrameType,
|
||||
channel: u16,
|
||||
pub kind: FrameType,
|
||||
pub channel: u16,
|
||||
/// Includes the whole payload, also including the metadata from each type.
|
||||
payload: Vec<u8>,
|
||||
pub payload: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
@ -29,23 +29,6 @@ pub enum FrameType {
|
|||
Heartbeat = 8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum FrameTypeEnum {
|
||||
/// 1
|
||||
Method,
|
||||
/// 2
|
||||
Header {
|
||||
class_id: u16,
|
||||
body_size: u64,
|
||||
/// Ordered from high to low
|
||||
property_flags: u16,
|
||||
},
|
||||
/// 3
|
||||
Body,
|
||||
/// 8
|
||||
Heartbeat,
|
||||
}
|
||||
|
||||
pub async fn read_frame<R>(r: &mut R, max_frame_size: usize) -> Result<Frame, TransError>
|
||||
where
|
||||
R: AsyncReadExt + Unpin,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue