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: RestrictedExpr) -> Result<Self, RestrictedExpr>
pub fn from_expr(expr: RestrictedExpr) -> Result<Self, RestrictedExpr>
Create a Context
from a RestrictedExpr
, which must be a Record
.
If it is not a Record
, then this function returns Err
(returning
ownership of the non-record expression), otherwise it returns Ok
of
a context for that record.
sourcepub fn from_pairs(
pairs: impl IntoIterator<Item = (SmolStr, RestrictedExpr)>,
) -> Self
pub fn from_pairs( pairs: impl IntoIterator<Item = (SmolStr, RestrictedExpr)>, ) -> Self
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
sourcepub fn from_json_str(json: &str) -> Result<Self, JsonDeserializationError>
pub fn from_json_str(json: &str) -> Result<Self, JsonDeserializationError>
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, JsonDeserializationError>
pub fn from_json_value(json: Value) -> Result<Self, JsonDeserializationError>
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, JsonDeserializationError>
pub fn from_json_file(json: impl Read) -> Result<Self, JsonDeserializationError>
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 iter(&self) -> impl Iterator<Item = (&str, BorrowedRestrictedExpr<'_>)>
pub fn iter(&self) -> impl Iterator<Item = (&str, BorrowedRestrictedExpr<'_>)>
Iterate over the (key, value) pairs in the Context
Trait Implementations§
source§impl AsRef<RestrictedExpr> for Context
impl AsRef<RestrictedExpr> for Context
source§fn as_ref(&self) -> &RestrictedExpr
fn as_ref(&self) -> &RestrictedExpr
source§impl<'de> Deserialize<'de> for Context
impl<'de> Deserialize<'de> for Context
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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