pub struct TileDef {
pub name: String,
pub encoding: Option<String>,
pub options: TileOptions,
pub body_kind: TileBodyKind,
pub pieces: Vec<TilePiece>,
pub span: Span,
}Expand description
A tile definition: its header, its raw body, and the parsed template.
Fields§
§name: StringThe tile’s name: the wire it binds.
encoding: Option<String>The declared encoding, such as json or csv, if any.
options: TileOptionsThe delimiter and strictness options.
body_kind: TileBodyKindHow the body was written: heredoc, block, or string literal. Presentation, not content: it decides how the body is delimited when the tile is printed.
pieces: Vec<TilePiece>The template: static runs, holes, projections, and branches. This is the tile’s body — the only representation of it. Text admitted from source is parsed into pieces under the options in force at that moment and is not kept beside them.
span: SpanWhere the definition appears.
Implementations§
Source§impl TileDef
impl TileDef
Sourcepub fn from_body(
name: impl Into<String>,
encoding: Option<String>,
options: TileOptions,
body_kind: TileBodyKind,
body: impl Into<String>,
span: Span,
) -> Result<Self, String>
pub fn from_body( name: impl Into<String>, encoding: Option<String>, options: TileOptions, body_kind: TileBodyKind, body: impl Into<String>, span: Span, ) -> Result<Self, String>
A tile whose body is admitted as text, parsed into pieces under the tile’s own options.
The text is consumed by this call: what the tile holds
afterwards is the template it parsed to. Reading the body back
renders from those pieces (Self::body_text), so the body a
tile prints is always the body it renders (polytile.md §3).
Sourcepub fn from_pieces(
name: impl Into<String>,
encoding: Option<String>,
options: TileOptions,
body_kind: TileBodyKind,
pieces: Vec<TilePiece>,
span: Span,
) -> Self
pub fn from_pieces( name: impl Into<String>, encoding: Option<String>, options: TileOptions, body_kind: TileBodyKind, pieces: Vec<TilePiece>, span: Span, ) -> Self
A tile whose body is admitted as pieces, built directly.
The counterpart of Self::from_body, and the same tile: a
template composed programmatically and one parsed from text that
renders the same pieces are equal as tiles, because the pieces
are what a tile is. Pieces from either source compose by
concatenation, so a template may be assembled from parsed
fragments, hand-built pieces, or any mixture, in any order.
Sourcepub fn body_text(&self) -> String
pub fn body_text(&self) -> String
The body as template text, rendered from the pieces under this tile’s own delimiters and sigil.
Canonical rather than verbatim: a tile parsed from source does not keep the author’s spacing, the same way the projector does not keep the spacing around a binary operator. Re-parsing this text under the same options yields the same pieces.