pub struct Field {
pub field: &'static str,
pub written: Written,
}Expand description
One field of a presentation payload, and what becomes of it.
Fields§
§field: &'static strThe field’s name, spelled as the payload’s projection spells it.
written: WrittenWhat the emitter does with it.
Implementations§
Source§impl Field
impl Field
Sourcepub fn attribute(&self) -> Option<String>
pub fn attribute(&self) -> Option<String>
The attribute this field is written under on the element’s own tag,
when it is written as one there. A field written on each entry of a
list (Written::Entry, Written::EntryData) returns None here and its attribute from
entry_attribute; a length field
(Written::Style) returns None and its custom property from
style_property, all of a row’s length
fields sharing the single STYLE_ATTRIBUTE.
§Examples
use flm_core::stdlib::backends::html::conventions::{Field, Written};
let level = Field { field: "level", written: Written::Data("level") };
assert_eq!(level.attribute().as_deref(), Some("data-flm-level"));
let role = Field { field: "role", written: Written::RoleClass };
assert_eq!(role.attribute(), None);Sourcepub fn style_property(&self) -> Option<String>
pub fn style_property(&self) -> Option<String>
The custom property this field is written as in the element’s style
attribute, when it is a length field written there
(Written::Style) or a ratio of two (Written::Ratio).
§Examples
use flm_core::stdlib::backends::html::conventions::row;
use flm_core::stdlib::backends::pres;
let line = row(pres::LINE).expect("a row");
let indent = line.field("indent_left").expect("the field");
assert_eq!(indent.style_property().as_deref(), Some("--flm-element-indent-left"));
assert_eq!(indent.attribute(), None);Sourcepub fn entry_attribute(&self) -> Option<String>
pub fn entry_attribute(&self) -> Option<String>
The attribute this field is written under on the element of each
entry of a list or each cell of a table of cells, when it is written
there: the name given for Written::Entry, and the name
data_attribute derives from the token for Written::EntryData.
§Examples
use flm_core::stdlib::backends::html::conventions::row;
use flm_core::stdlib::backends::pres;
let list = row(pres::LIST).expect("a row");
let anchors = list.field("entry_anchors").expect("the field");
assert_eq!(anchors.entry_attribute().as_deref(), Some("id"));
assert_eq!(anchors.attribute(), None);
let levels = list.field("entry_levels").expect("the field");
assert_eq!(levels.entry_attribute().as_deref(), Some("data-flm-level"));Trait Implementations§
impl Copy for Field
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Forget for Field
impl Freeze for Field
impl Move for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Fieldwhere
&'static str: UnsafeUnpin,
impl UnwindSafe for Fieldwhere
&'static str: UnwindSafe,
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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