|
|
@ -32,17 +32,6 @@ enum ReadingState { |
|
|
|
Payload, |
|
|
|
Payload, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub struct MessageReader { |
|
|
|
|
|
|
|
is_broken: bool, |
|
|
|
|
|
|
|
reading_state: ReadingState, |
|
|
|
|
|
|
|
read_bytes: usize, |
|
|
|
|
|
|
|
length_buffer: [u8; 4], |
|
|
|
|
|
|
|
current_message_length: usize, |
|
|
|
|
|
|
|
current_message: Vec<u8>, |
|
|
|
|
|
|
|
read_messages: VecDeque<String>, |
|
|
|
|
|
|
|
ue_received_bytes: u64, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// For converting byte stream that is expected from the ue-server into actual messages.
|
|
|
|
/// For converting byte stream that is expected from the ue-server into actual messages.
|
|
|
|
/// Expected format is a sequence of either:
|
|
|
|
/// Expected format is a sequence of either:
|
|
|
|
/// 1. [HEAD_UE_RECEIVED: marker byte | 1 byte]
|
|
|
|
/// 1. [HEAD_UE_RECEIVED: marker byte | 1 byte]
|
|
|
@ -54,6 +43,17 @@ pub struct MessageReader { |
|
|
|
/// never recovers from it.
|
|
|
|
/// never recovers from it.
|
|
|
|
/// Use either `push_byte()` or `push()` to input byte stream from ue-server and `pop()` to
|
|
|
|
/// Use either `push_byte()` or `push()` to input byte stream from ue-server and `pop()` to
|
|
|
|
/// retrieve resulting messages.
|
|
|
|
/// retrieve resulting messages.
|
|
|
|
|
|
|
|
pub struct MessageReader { |
|
|
|
|
|
|
|
is_broken: bool, |
|
|
|
|
|
|
|
reading_state: ReadingState, |
|
|
|
|
|
|
|
read_bytes: usize, |
|
|
|
|
|
|
|
length_buffer: [u8; 4], |
|
|
|
|
|
|
|
current_message_length: usize, |
|
|
|
|
|
|
|
current_message: Vec<u8>, |
|
|
|
|
|
|
|
read_messages: VecDeque<String>, |
|
|
|
|
|
|
|
ue_received_bytes: u64, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl MessageReader { |
|
|
|
impl MessageReader { |
|
|
|
pub fn new() -> MessageReader { |
|
|
|
pub fn new() -> MessageReader { |
|
|
|
MessageReader { |
|
|
|
MessageReader { |
|
|
|