pub struct FormatString { /* private fields */ }Implementations§
Source§impl FormatString
impl FormatString
Sourcepub fn new(input: &str) -> Result<FormatString, ExpressionError>
pub fn new(input: &str) -> Result<FormatString, 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.
Sourcepub fn with_profile(
input: &str,
profile: &ExprProfile,
) -> Result<FormatString, ExpressionError>
pub fn with_profile( input: &str, profile: &ExprProfile, ) -> Result<FormatString, 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.
pub fn raw(&self) -> &str
Sourcepub fn resolve_with(
&self,
symtab: &SymbolTable,
opts: &FormatStringOptions<'_>,
) -> Result<ExprValue, ExpressionError>
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.
Sourcepub fn resolve_string_with(
&self,
symtab: &SymbolTable,
opts: &FormatStringOptions<'_>,
) -> Result<String, ExpressionError>
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::Posixin template context (create_job, let bindings)PathFormat::host()in session/host context (action execution)
Sourcepub fn validate_expressions(
&self,
symtab: &SymbolTable,
lib: &FunctionLibrary,
) -> Result<(), FormatStringValidationError>
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.
Sourcepub fn validate_comprehension_vars(
&self,
let_names: &HashSet<String>,
) -> Result<(), ExpressionError>
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.
Sourcepub fn has_complex_expressions(&self) -> bool
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).
Sourcepub fn expression_names(&self) -> Vec<&str>
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.
pub fn is_literal(&self) -> bool
Sourcepub fn copy_used_symtab_values(
&self,
source: &SymbolTable,
dest: &mut SymbolTable,
)
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.
Sourcepub fn accessed_symbols(&self) -> HashSet<String>
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
impl Clone for FormatString
Source§fn clone(&self) -> FormatString
fn clone(&self) -> FormatString
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FormatString
impl Debug for FormatString
Source§impl<'de> Deserialize<'de> for FormatString
impl<'de> Deserialize<'de> for FormatString
Source§fn deserialize<D>(
deserializer: D,
) -> Result<FormatString, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<FormatString, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for FormatString
impl Display for FormatString
Source§impl PartialEq for FormatString
impl PartialEq for FormatString
Source§fn eq(&self, other: &FormatString) -> bool
fn eq(&self, other: &FormatString) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for FormatString
impl Serialize for FormatString
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for FormatString
Auto Trait Implementations§
impl Freeze for FormatString
impl RefUnwindSafe for FormatString
impl Send for FormatString
impl Sync for FormatString
impl Unpin for FormatString
impl UnsafeUnpin for FormatString
impl UnwindSafe for FormatString
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§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<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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more