Skip to main content

layline_codegen/
model.rs

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