Skip to main content

TileDef

Struct TileDef 

Source
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: String

The tile’s name: the wire it binds.

§encoding: Option<String>

The declared encoding, such as json or csv, if any.

§options: TileOptions

The delimiter and strictness options.

§body_kind: TileBodyKind

How 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: Span

Where the definition appears.

Implementations§

Source§

impl TileDef

Source

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).

Source

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.

Source

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§

Source§

impl Clone for TileDef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TileDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.