Skip to main content

FormatString

Struct FormatString 

Source
pub struct FormatString { /* private fields */ }

Implementations§

Source§

impl FormatString

Source

pub fn new(input: &str) -> Result<Self, ExpressionError>

Parse a format string using the “latest” profile (ExprProfile::latest): the current revision with every known extension enabled.

This constructor is intentionally unstable across crate versions. The set of accepted syntax, functions, and types grows as new extensions and revisions land. Use it for ad-hoc parsing or prototyping.

For stability across crate versions, build a profile with an explicit revision and extension set and use with_profile.

Source

pub fn with_profile( input: &str, profile: &ExprProfile, ) -> Result<Self, ExpressionError>

Parse a format string under a caller-supplied profile.

Each {{...}} interpolation is parsed as an expression under the same profile, so the syntax features accepted inside interpolations are determined by the profile in exactly the same way as ParsedExpression::with_profile.

Source

pub fn raw(&self) -> &str

Source

pub fn resolve_with( &self, symtab: &SymbolTable, opts: &FormatStringOptions<'_>, ) -> Result<ExprValue, ExpressionError>

Resolve to an ExprValue.

Configures evaluation via FormatStringOptions. If the format string is a single expression with no surrounding literal text, returns the raw typed ExprValue (which may be int, list, path, etc.); otherwise it concatenates all segments and returns ExprValue::String.

Pass &FormatStringOptions::default() for the simplest call. Build options with .with_library(...), .with_path_format(...), and .with_target_type(...). Path mapping rules, if needed, are baked into the library via FunctionLibrary::for_profile with an ExprProfile whose host context is HostContext::WithRules.

Source

pub fn resolve_string_with( &self, symtab: &SymbolTable, opts: &FormatStringOptions<'_>, ) -> Result<String, ExpressionError>

Resolve to String, concatenating every segment.

Single-expression format strings lose their typed value — use resolve_with when you need the native ExprValue. The target_type field on opts is ignored here.

path_format on the options controls how path() values are constructed:

  • PathFormat::Posix in template context (create_job, let bindings)
  • PathFormat::host() in session/host context (action execution)
Source

pub fn validate_expressions( &self, symtab: &SymbolTable, lib: &FunctionLibrary, ) -> Result<(), FormatStringValidationError>

Validate all expressions in this format string against a symbol table. The symbol table should contain ExprValue::unresolved(T) for symbols whose values are not yet known. This is the spec’s approach to static type checking — just evaluate normally with unresolved types.

Source

pub fn validate_comprehension_vars( &self, let_names: &HashSet<String>, ) -> Result<(), ExpressionError>

Validate list comprehension loop variables in expressions. Checks: must be lowercase, must not shadow let bindings.

Source

pub fn has_complex_expressions(&self) -> bool

True if any {{...}} segment is more than a bare dotted-name lookup (e.g., contains arithmetic, function calls, or list comprehensions — anything that requires the EXPR extension).

Source

pub fn expression_names(&self) -> Vec<&str>

Names of all bare dotted-name interpolations ({{Param.Name}}-style). Complex expressions (arithmetic, function calls, etc.) are not included — callers that want all referenced symbols should use accessed_symbols.

Source

pub fn is_literal(&self) -> bool

Source

pub fn copy_used_symtab_values( &self, source: &SymbolTable, dest: &mut SymbolTable, )

Copy symbol table entries referenced by this format string’s expressions from source into dest. Only copies the actual symtab values that are referenced, not properties/methods called on them.

For example, if an expression references Param.Name.upper(), the symbol Param.Name is a Value in the symtab (.upper() is a method call). This method walks the dotted path into source, stops when it finds a Value (not a Table), and copies that value into dest at the same path.

Source

pub fn accessed_symbols(&self) -> HashSet<String>

Returns the set of symbol names accessed by this format string.

Trait Implementations§

Source§

impl Clone for FormatString

Source§

fn clone(&self) -> FormatString

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 FormatString

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FormatString

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for FormatString

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FormatString

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for FormatString

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for FormatString

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToCompactString for T
where T: Display,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,