Skip to main content

layline_codegen/
model.rs

1//! The layout model: generator input as plain data.
2
3mod choice;
4mod coverage;
5mod derive;
6mod dispatch;
7mod enumeration;
8mod field;
9mod layout;
10mod message;
11
12pub use choice::{Arm, ChoiceDef, Discriminant};
13pub use coverage::{CoverFrom, CoverTo, Coverage, Covered};
14pub use derive::Derive;
15pub use dispatch::{DispatchArm, DispatchDef};
16pub use enumeration::{EnumDef, Variant};
17pub use field::{By, Field, Kind, Len, Range, Scalar, Stated};
18pub(crate) use layout::positioned;
19pub use layout::{BitOrder, Container, Endian, LayoutDef, Unit};
20pub use message::{Absence, Collection, Count, MessageDef, Param, Presence, Segment, split_ref};
21
22/// One item of a model.
23#[derive(Debug, Clone)]
24#[non_exhaustive]
25pub enum Item {
26    /// An enumeration.
27    Enum(EnumDef),
28    /// A fixed-size layout.
29    Layout(LayoutDef),
30    /// The arms of a [`Segment::Switch`].
31    Choice(ChoiceDef),
32    /// Bodies selected by an id the enclosing message has already read.
33    Dispatch(DispatchDef),
34    /// A variable-length message.
35    Message(MessageDef),
36    /// Rust code copied into the output as is, such as accessors, trait impls and constants.
37    ///
38    /// Refused if it declares a codec, since the model generates those.
39    #[cfg(feature = "walk")]
40    Verbatim(proc_macro2::TokenStream),
41}