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<TileDef, String>
pub fn from_body( name: impl Into<String>, encoding: Option<String>, options: TileOptions, body_kind: TileBodyKind, body: impl Into<String>, span: Span, ) -> Result<TileDef, 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,
) -> TileDef
pub fn from_pieces( name: impl Into<String>, encoding: Option<String>, options: TileOptions, body_kind: TileBodyKind, pieces: Vec<TilePiece>, span: Span, ) -> TileDef
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TileDef
impl RefUnwindSafe for TileDef
impl Send for TileDef
impl Sync for TileDef
impl Unpin for TileDef
impl UnsafeUnpin for TileDef
impl UnwindSafe for TileDef
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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