pub enum Context {
Value(Arc<BTreeMap<SmolStr, Value>>),
RestrictedResidual(Arc<BTreeMap<SmolStr, Expr>>),
}
Expand description
Context
field of a Request
Variants§
Value(Arc<BTreeMap<SmolStr, Value>>)
The context is a concrete value.
RestrictedResidual(Arc<BTreeMap<SmolStr, Expr>>)
The context is a residual expression, containing some unknown value in
the record attributes.
INVARIANT(restricted): Each Expr
in this map must be a RestrictedExpr
.
INVARIANT(unknown): At least one Expr
must contain an unknown
.
Implementations§
Source§impl Context
impl Context
Sourcepub fn from_expr(
expr: BorrowedRestrictedExpr<'_>,
extensions: &Extensions<'_>,
) -> Result<Self, ContextCreationError>
pub fn from_expr( expr: BorrowedRestrictedExpr<'_>, extensions: &Extensions<'_>, ) -> Result<Self, ContextCreationError>
Create a Context
from a RestrictedExpr
, which must be a Record
.
extensions
provides the Extensions
which should be active for
evaluating the RestrictedExpr
.
Sourcepub fn from_pairs(
pairs: impl IntoIterator<Item = (SmolStr, RestrictedExpr)>,
extensions: &Extensions<'_>,
) -> Result<Self, ContextCreationError>
pub fn from_pairs( pairs: impl IntoIterator<Item = (SmolStr, RestrictedExpr)>, extensions: &Extensions<'_>, ) -> Result<Self, ContextCreationError>
Create a Context
from a map of key to RestrictedExpr
, or a Vec of
(key, RestrictedExpr)
pairs, or any other iterator of (key, RestrictedExpr)
pairs
extensions
provides the Extensions
which should be active for
evaluating the RestrictedExpr
.
Sourcepub fn from_json_str(
json: &str,
) -> Result<Self, ContextJsonDeserializationError>
pub fn from_json_str( json: &str, ) -> Result<Self, ContextJsonDeserializationError>
Create a Context
from a string containing JSON (which must be a JSON
object, not any other JSON type, or you will get an error here).
JSON here must use the __entity
and __extn
escapes for entity
references, extension values, etc.
For schema-based parsing, use ContextJsonParser
.
Sourcepub fn from_json_value(
json: Value,
) -> Result<Self, ContextJsonDeserializationError>
pub fn from_json_value( json: Value, ) -> Result<Self, ContextJsonDeserializationError>
Create a Context
from a serde_json::Value
(which must be a JSON
object, not any other JSON type, or you will get an error here).
JSON here must use the __entity
and __extn
escapes for entity
references, extension values, etc.
For schema-based parsing, use ContextJsonParser
.
Sourcepub fn from_json_file(
json: impl Read,
) -> Result<Self, ContextJsonDeserializationError>
pub fn from_json_file( json: impl Read, ) -> Result<Self, ContextJsonDeserializationError>
Create a Context
from a JSON file. The JSON file must contain a JSON
object, not any other JSON type, or you will get an error here.
JSON here must use the __entity
and __extn
escapes for entity
references, extension values, etc.
For schema-based parsing, use ContextJsonParser
.
Sourcepub fn substitute(
self,
mapping: &HashMap<SmolStr, Value>,
) -> Result<Self, EvaluationError>
pub fn substitute( self, mapping: &HashMap<SmolStr, Value>, ) -> Result<Self, EvaluationError>
Substitute unknowns with concrete values in this context. If this is
already a Context::Value
, then this returns self
unchanged and will
not error. Otherwise delegate to Expr::substitute
.
Trait Implementations§
Source§impl From<Context> for PartialValue
impl From<Context> for PartialValue
Source§fn from(ctx: Context) -> PartialValue
fn from(ctx: Context) -> PartialValue
Source§impl From<Context> for RestrictedExpr
impl From<Context> for RestrictedExpr
Source§impl IntoIterator for Context
impl IntoIterator for Context
impl StructuralPartialEq for Context
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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