Struct cedar_policy_core::ast::Context
source · pub struct Context { /* private fields */ }
Expand description
Context
field of a Request
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
.