Struct ULogParser

Source
pub struct ULogParser<R: Read> { /* private fields */ }
Expand description

A parser for ULog binary data.

The ULogParser struct is responsible for parsing the binary data of a ULog file. It provides methods to access the various components of the ULog data, such as the header, format messages, subscriptions, logged messages, and parameter messages.

The parser is generic over the Read trait, allowing it to work with different types of input sources, such as files, network streams, or in-memory buffers.

Implementations§

Source§

impl<R: Read> ULogParser<R>

Source

pub fn read_data_message( &mut self, msg_id: u16, msg_size: u16, format: &FormatMessage, ) -> Result<DataMessage, ULogError>

Reads a data message from the ULog file and returns a DataMessage struct containing the parsed data.

This function takes the message ID, message size, and the format of the message as input. It then reads the message data, parsing the values according to the specified format, and returns a DataMessage struct containing the parsed data.

The function handles padding fields, nested messages, and any remaining bytes in the message. It also updates the current timestamp if a new timestamp value is present in the message data.

§Arguments
  • msg_id - The ID of the message to be read.
  • msg_size - The size of the message in bytes.
  • format - The format of the message, as a FormatMessage struct.
§Returns

A Result containing a DataMessage struct with the parsed data, or a ULogError if there was an error parsing the message.

Source

pub fn handle_data_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>

Source§

impl<R: Read> ULogParser<R>

Source

pub fn handle_dropout( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>

Source

pub fn dropout_details(&self) -> &DropoutStats

Source§

impl<R: Read> ULogParser<R>

Source

pub fn formats(&self) -> &HashMap<String, FormatMessage>

Source

pub fn read_format_message( &mut self, msg_size: u16, ) -> Result<FormatMessage, ULogError>

Source

pub fn handle_format_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>

Source§

impl<R: Read> ULogParser<R>

Source§

impl<R: Read> ULogParser<R>

Source

pub fn logged_messages(&self) -> &[LoggedMessage]

Source

pub fn log_level_to_string(level: u8) -> &'static str

Source

pub fn handle_logged_message( &mut self, header: &MessageHeader, ) -> Result<(), ULogError>

Source§

impl<R: Read> ULogParser<R>

Source§

impl<R: Read> ULogParser<R>

Source§

impl<R: Read> ULogParser<R>

Source§

impl<R: Read> ULogParser<R>

Source§

impl<R: Read> ULogParser<R>

Source

pub fn new(reader: R) -> Result<Self, ULogError>

Source

pub fn header(&self) -> &ULogHeader

Source

pub fn read_message_header(&mut self) -> Result<MessageHeader, ULogError>

Source

pub fn read_flag_bits(&mut self) -> Result<FlagBitsMessage, ULogError>

Source

pub fn parse_definitions(&mut self) -> Result<(), ULogError>

Parses the definitions section of the ULog file until the data section is reached. This method reads the flag bits message first, then iterates through the definition section, handling various message types such as info messages, format messages, initial parameters, and multi messages. Once the first subscription message is encountered, the method breaks out of the loop to continue parsing the data section.

Source

pub fn parse_data(&mut self) -> Result<(), ULogError>

Parses the data section of the ULog file, handling various message types such as subscription messages, info messages, multi messages, logged messages, data messages, parameter changes, and dropouts. The method reads the message headers and dispatches to the appropriate handler for each message type. If an unknown message type is encountered, the message is skipped. The method continues parsing the data section until the end of the file is reached.

Source

pub fn parse_reader(reader: R) -> Result<ULogParser<R>, ULogError>

Main method to create a new ULogParser instance.

This function creates a new ULogParser instance, parses the definitions, and then parses the data from the reader. If any errors occur during the parsing process, they are returned as a ULogError.

Source

pub fn last_timestamp(&self) -> u64

Trait Implementations§

Source§

impl<R: Debug + Read> Debug for ULogParser<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for ULogParser<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for ULogParser<R>
where R: RefUnwindSafe,

§

impl<R> Send for ULogParser<R>
where R: Send,

§

impl<R> Sync for ULogParser<R>
where R: Sync,

§

impl<R> Unpin for ULogParser<R>
where R: Unpin,

§

impl<R> UnwindSafe for ULogParser<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.