pub struct ExprProfile { /* private fields */ }Expand description
A complete expression profile: revision, enabled extensions, and host context.
Passed to
FunctionLibrary::for_profile
to obtain a library matching the profile.
§Examples
use openjd_expr::{ExprProfile, ExprRevision, HostContext, FunctionLibrary};
// Default profile: current revision, no extensions, no host context.
let profile = ExprProfile::current();
let lib = FunctionLibrary::for_profile(&profile);
assert!(!lib.host_context_enabled);
// Template-validation profile: same as above but with unresolved host.
let profile = ExprProfile::current().with_host_context(HostContext::Unresolved);
let lib = FunctionLibrary::for_profile(&profile);
assert!(lib.host_context_enabled);Implementations§
Source§impl ExprProfile
impl ExprProfile
Sourcepub fn new(revision: ExprRevision) -> Self
pub fn new(revision: ExprRevision) -> Self
Build a profile for the given revision with no extensions and no host context.
Sourcepub fn current() -> Self
pub fn current() -> Self
Shortcut for ExprProfile::new(ExprRevision::CURRENT).
Builds a profile with the current revision, no extensions, and
no host context. Use this when you want a stable baseline: future
crate versions that ship a new revision will change what
ExprRevision::CURRENT points to, but the extensions set will
remain explicitly empty, and the accepted syntax/functions are
whatever the current revision defines without opt-in.
Sourcepub fn latest() -> Self
pub fn latest() -> Self
Build a profile with the latest revision and every known extension enabled.
This profile is intentionally unstable across crate versions.
As new extensions are added to ExprExtension::ALL and new
revisions land at ExprRevision::CURRENT, the set of accepted
syntax, functions, and types grows. An expression that parses
under latest() today may fail to parse against a future version
of this crate if its meaning changes under the new revision.
ParsedExpression::new and FormatString::new use this profile
as a quick-start default. For parse behavior that is stable
across crate versions, construct a profile with an explicit
revision and extension set via ExprProfile::new or
ExprProfile::current and use
ParsedExpression::with_profile
/ FormatString::with_profile.
Sourcepub fn with_extensions(self, extensions: HashSet<ExprExtension>) -> Self
pub fn with_extensions(self, extensions: HashSet<ExprExtension>) -> Self
Set the enabled extensions (replaces any existing set).
Sourcepub fn with_host_context(self, host_context: HostContext) -> Self
pub fn with_host_context(self, host_context: HostContext) -> Self
Set the host context.
Sourcepub fn revision(&self) -> ExprRevision
pub fn revision(&self) -> ExprRevision
The specification revision this profile targets.
Sourcepub fn extensions(&self) -> &HashSet<ExprExtension>
pub fn extensions(&self) -> &HashSet<ExprExtension>
The set of enabled extensions.
Sourcepub fn host_context(&self) -> &HostContext
pub fn host_context(&self) -> &HostContext
The host context.
Sourcepub fn has_extension(&self, ext: ExprExtension) -> bool
pub fn has_extension(&self, ext: ExprExtension) -> bool
Whether the given extension is enabled in this profile.
Trait Implementations§
Source§impl Clone for ExprProfile
impl Clone for ExprProfile
Source§fn clone(&self) -> ExprProfile
fn clone(&self) -> ExprProfile
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 ExprProfile
impl Debug for ExprProfile
Auto Trait Implementations§
impl Freeze for ExprProfile
impl RefUnwindSafe for ExprProfile
impl Send for ExprProfile
impl Sync for ExprProfile
impl Unpin for ExprProfile
impl UnsafeUnpin for ExprProfile
impl UnwindSafe for ExprProfile
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<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 more