pub struct Element {
pub name: String,
pub id: Option<String>,
pub limits: Limits,
pub children: Vec<Node>,
pub position: Position,
}Expand description
A named grouping. Names and optional IDs have no provider role or trust meaning.
Fields§
§name: String§id: Option<String>§limits: Limits§children: Vec<Node>§position: PositionImplementations§
Source§impl Element
impl Element
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Construct a named element with no ID. Names are validated by lint/render.
pub fn id(self, id: impl Into<String>) -> Self
Sourcepub fn text(self, value: impl Into<String>) -> Self
pub fn text(self, value: impl Into<String>) -> Self
Append literal text. Braces, entities, and markup are never interpreted.
pub fn variable(self, name: impl Into<String>) -> Self
Sourcepub fn template(self, value: &str) -> Result<Self, Diagnostic>
pub fn template(self, value: &str) -> Result<Self, Diagnostic>
Append a text template. Only {{name}} is interpreted; bindings remain literal.
pub fn element(self, element: Element) -> Self
pub fn max_tokens(self, tokens: u64, reason: impl Into<String>) -> Self
pub fn per_item(self, tokens: u64, reason: impl Into<String>) -> Self
pub fn get_element_by_id(&self, id: &str) -> Option<ElementRef<'_>>
pub fn elements(&self) -> Vec<&Element>
pub fn elements_by_name(&self, name: &str) -> Vec<&Element>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Element
impl<'de> Deserialize<'de> for Element
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Element
Source§impl JsonSchema for Element
impl JsonSchema for Element
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Element
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnsafeUnpin for Element
impl UnwindSafe for Element
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
Mutably borrows from an owned value. Read more