Skip to main content

ModelProfile

Struct ModelProfile 

Source
pub struct ModelProfile { /* private fields */ }
Expand description

Model-side profile: the specification revision plus the set of enabled extensions that together describe what features a template or job may use.

ModelProfile is the openjd-model counterpart of openjd_expr::ExprProfile. Both crates share the pattern:

Profiles are small value types: clone them freely, store them on sessions, pass them by reference into validators. ModelProfile has no mutable operations other than builder-style with_* methods that return a new profile.

Use ModelProfile::to_expr_profile to derive a matching ExprProfile when calling into openjd-expr; the caller supplies the appropriate HostContext for their situation.

Implementations§

Source§

impl ModelProfile

Source

pub fn new(revision: SpecificationRevision) -> Self

Build a profile for the given revision with no extensions enabled.

Source

pub fn with_extensions(self, extensions: Extensions) -> Self

Set the enabled extensions (replaces any existing set).

Source

pub fn revision(&self) -> SpecificationRevision

The specification revision this profile targets.

Source

pub fn extensions(&self) -> &Extensions

The set of extensions this profile enables.

Source

pub fn has_extension(&self, ext: ModelExtension) -> bool

True iff ext is enabled in this profile.

Source

pub fn to_expr_profile(&self, host_context: HostContext) -> ExprProfile

Derive an ExprProfile matching this profile’s revision and extensions, with the caller-specified HostContext.

This is the bridge from openjd-model to openjd-expr: call this and pass the result to FunctionLibrary::for_profile.

The host_context argument is a caller responsibility because the model has no opinion on it — template validation uses HostContext::Unresolved, runtime session work uses HostContext::WithRules, and pure-template work (e.g. resolving the job name) uses HostContext::None.

Trait Implementations§

Source§

impl Clone for ModelProfile

Source§

fn clone(&self) -> ModelProfile

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 ModelProfile

Source§

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

Formats the value using the given formatter. Read more

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<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> 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, 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.