Struct cedar_policy_core::entities::ValueParser
source · pub struct ValueParser<'e> { /* private fields */ }
Expand description
Struct used to parse Cedar values from JSON.
Implementations§
source§impl<'e> ValueParser<'e>
impl<'e> ValueParser<'e>
sourcepub fn new(extensions: Extensions<'e>) -> Self
pub fn new(extensions: Extensions<'e>) -> Self
Create a new ValueParser
.
sourcepub fn val_into_rexpr(
&self,
val: Value,
expected_ty: Option<&SchemaType>,
ctx: impl Fn() -> JsonDeserializationErrorContext + Clone,
) -> Result<RestrictedExpr, JsonDeserializationError>
pub fn val_into_rexpr( &self, val: Value, expected_ty: Option<&SchemaType>, ctx: impl Fn() -> JsonDeserializationErrorContext + Clone, ) -> Result<RestrictedExpr, JsonDeserializationError>
internal function that converts a Cedar value (in JSON) into a
RestrictedExpr
. Performs schema-based parsing if expected_ty
is
provided.
sourcepub fn type_of_rexpr(
&self,
rexpr: BorrowedRestrictedExpr<'_>,
ctx: impl Fn() -> JsonDeserializationErrorContext + Clone,
) -> Result<SchemaType, JsonDeserializationError>
pub fn type_of_rexpr( &self, rexpr: BorrowedRestrictedExpr<'_>, ctx: impl Fn() -> JsonDeserializationErrorContext + Clone, ) -> Result<SchemaType, JsonDeserializationError>
Get the SchemaType
of a restricted expression.
This isn’t possible for general Expr
s (without a Request, full schema,
etc), but is possible for restricted expressions, given the information
in Extensions
.
Trait Implementations§
source§impl<'e> Clone for ValueParser<'e>
impl<'e> Clone for ValueParser<'e>
source§fn clone(&self) -> ValueParser<'e>
fn clone(&self) -> ValueParser<'e>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<'e> Freeze for ValueParser<'e>
impl<'e> !RefUnwindSafe for ValueParser<'e>
impl<'e> Send for ValueParser<'e>
impl<'e> Sync for ValueParser<'e>
impl<'e> Unpin for ValueParser<'e>
impl<'e> !UnwindSafe for ValueParser<'e>
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
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>
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 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>
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