pub struct MessageParser { /* private fields */ }Expand description
A stateful parser that reconstructs fully attributed LogsData records from a stream of
FXT log packets.
§Background & Architecture
In the Fuchsia Trace Format (FXT) structured logging protocol, log attribution metadata is separated from the actual log payload to optimize transmission overhead. Instead of repeating the full moniker and component URL on every log record, the system transmits two distinct types of records:
- Manifest/Control Records: Sent with the
LOG_CONTROL_BITset. These records map a numeric base tag ID to component identity metadata (ExtendedMonikerand URL). - Legacy Log Records: Contain the message content, severity, timestamp, and arguments, along with a tag ID indicating which component produced the log.
§Stateful Parsing
MessageParser maintains an internal tag_map to track the active association between
numeric tag IDs and their component identity (ExtendedMetadata).
- When parsing a manifest record (
is_control == true),MessageParserupdates its state mapping for the derived base tag. If the record also reports rolled out (dropped) logs, aLogsDatapayload representing those dropped logs is returned. Otherwise, it registers the attribution mapping and returnsOk((None, remaining)). - When parsing a legacy log record (
is_control == false),MessageParserresolves the record’s tag to retrieve the component’s identity from the internal mapping, constructing a fully attributedLogsDatacontaining the correct component moniker and URL.
Implementations§
Source§impl MessageParser
impl MessageParser
Sourcepub fn parse_next<'a, F: MessageFormatter>(
&mut self,
bytes: &'a [u8],
formatter: F,
) -> Result<(Option<F::Result>, &'a [u8]), MessageError>
pub fn parse_next<'a, F: MessageFormatter>( &mut self, bytes: &'a [u8], formatter: F, ) -> Result<(Option<F::Result>, &'a [u8]), MessageError>
Parses the next log record from the given bytes.
This function can handle both standard log records and “Archivist” manifest records. Archivist records update an internal map used to attribute subsequent log records.
§Arguments
bytes: A byte slice containing one or more log records.
§Returns
A Result containing:
Ok((Option<LogsData>, &[u8])): A tuple where the first element isSome(LogsData)if a log message was parsed, orNoneif it was an Archivist manifest record. The second element is the remaining slice of bytes after parsing the record.Err(MessageError): An error if parsing failed.
Trait Implementations§
Source§impl Default for MessageParser
impl Default for MessageParser
Source§fn default() -> MessageParser
fn default() -> MessageParser
Auto Trait Implementations§
impl Freeze for MessageParser
impl RefUnwindSafe for MessageParser
impl Send for MessageParser
impl Sync for MessageParser
impl Unpin for MessageParser
impl UnsafeUnpin for MessageParser
impl UnwindSafe for MessageParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more