pub enum Language {
Plaintext,
Implicit,
Other(String),
}Expand description
Language tag for text values.
§Variants
-
Plaintext: Explicitly plain text, from"..."string syntax. Use when the content is data/text, not code. -
Implicit: No language specified, from`...`or```without a language tag. The language can be inferred from schema context. -
Other: Explicit language tag, fromrust`...`or```rustsyntax. Use when the language must be specified.
§Schema Validation
| Schema | Plaintext | Implicit | Other("rust") |
|---|---|---|---|
.text (any) | ✓ | ✓ | ✓ |
.text.plaintext | ✓ | ✓ (coerce) | ✗ |
.text.rust | ✗ | ✓ (coerce) | ✓ |
Implicit allows users to write `let a = 1;` when the schema
already specifies .text.rust, without redundantly repeating the language.
Variants§
Plaintext
Explicitly plain text (from "..." syntax).
This variant is rejected by schemas expecting a specific language like .text.rust.
Use this when the content is data/text, not code.
Implicit
No language specified (from `...` without language tag).
Can be coerced to match the schema’s expected language. This allows users
to write `let a = 1;` when the schema already specifies .text.rust.
Other(String)
Explicit language tag (from lang`...` syntax).
The string contains the language identifier (e.g., “rust”, “sql”, “email”).
Implementations§
Source§impl Language
impl Language
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the language as a string slice, or None for Implicit.
Sourcepub fn is_plaintext(&self) -> bool
pub fn is_plaintext(&self) -> bool
Returns true if this is the Plaintext variant.
Sourcepub fn is_implicit(&self) -> bool
pub fn is_implicit(&self) -> bool
Returns true if this is the Implicit variant.
Sourcepub fn is_compatible_with(&self, expected: &Language) -> bool
pub fn is_compatible_with(&self, expected: &Language) -> bool
Returns true if this language can be coerced to the expected language.
§Coercion Rules
Implicitcan be coerced to any language (it’s “infer from schema”)- Any language matches an
Implicitexpectation (schema says “any”) - Otherwise, languages must match exactly
pub fn is_other(&self, arg: &str) -> bool
Trait Implementations§
impl Eq for Language
impl StructuralPartialEq for Language
Auto Trait Implementations§
impl Freeze for Language
impl RefUnwindSafe for Language
impl Send for Language
impl Sync for Language
impl Unpin for Language
impl UnwindSafe for Language
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
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§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.