yule_log
A streaming ULOG parser written in Rust.
Features
- Memory Efficient: A stream-oriented design allows
yule_loghandle arbitrarily large files in real time without fully loading them into memory. - Derive API: Map LoggedData messages directly into your structs using the optional
macrosfeature. - Complete coverage: Supports all ULog message types.
- Binary fidelity: Can parse and re-emit a ULog file byte-for-byte identical to the original.
- Safe and robust: Full Rust type safety with comprehensive error handling.
🌟Improved performance
Version 0.4.0 is now 3.7× faster than the previous release 0.3.3. This was accomplished through optimising
the memory representation of the parsing results, which introduces minor breaking changes.
Derive API
The macros feature provides a serde-like experience, allowing ULOG data to be mapped directly into your own structs.
With this feature, there is no need to manually track subscription names, msg_ids, or field indices, the macros handle all of that for you automatically. The stream-oriented nature of the underlying parser is fully preserved.
User guide
1. Enable the feature in Cargo.toml
= { ="0.4", = ["macros"] }
2. Map subscriptions to structs
Define one struct for each ULOG subscription you want to map,
and annotate it with: #[derive(ULogData)].
Example:
In most cases, no extra config is needed—just name your struct and fields to match the names used in the ULOG. Only include the fields you need.
The macros will infer the ULOG names by converting your struct and field names to snake case.
By default, struct fields will be validated
against the ULOG file, and any missing fields will cause an error. This can be overriden by making a field an Option<T>, as shown above for extra_field.
💡Subscription and field names can also be specified using the #[yule_log] attribute. For
more information refer to the ULogData API docs.
3. List all subscriptions in an enum
Declare an enum where each variant wraps one of your ULogData structs, and annotate it with:
#[derive(ULogMessages)].
This enum will then become your interface to the data.
💡 Raw ULOG messages can also be captured by annotating an enum variant as follows:
Other,
4. Iterate through mapped messages
The derive macro will generate a ::stream() method on your enum, allowing the
messages to be easily retrieved.
Full example:
use File;
use BufReader;
use UlogMessage;
use ;
🔧 Builder Interface for Advanced Configuration
By default, the ::stream() method configures the parser to only yield messages that are mapped to enum variants;
LoggedData and AddSubscription messages are handled internally and not visible to the caller.
To override this default behaviour, the derive macro also generates a ::builder() API for
your LoggedMessages enum, allowing you to:
- Forward
LoggedDatamessages not mapped to an enum variant. - Forward
AddSubscriptionmessages.
💡It is recommended to only map the LoggedData messages you need, as this avoids
parsing of unmapped messages which improves performance. Unmapped LoggedData messages will
are returned in raw form as UlogMessage::Ignored.
Example Usage
let stream = builder
.add_subscription? // Add extra subscription
.forward_subscriptions? // Forward AddSubscription messages
.stream?; // Create the iterator
for msg_res in stream
Low Level API
For those requiring complete control over the parsing process, the original low level API is still available.
Example:
let reader = new;
let parser = new
.include_header
.include_timestamp
.include_padding
.build?;
for result in parser
This example is also available in the examples directory as simple.rs.
Notes
Thread Safety Feature
Enabling the optional thread_safe feature makes the parser’s data structures safe to use across threads.
Since the parser itself is single threaded, this feature is disabled by default.
Enabling this feature has a small (~2%) runtime cost due to atomic operations.
License
This project is licensed under the MIT Licence.