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