pub enum CedarValueJson {
    ExprEscape {
        __expr: SmolStr,
    },
    EntityEscape {
        __entity: TypeAndId,
    },
    ExtnEscape {
        __extn: FnAndArg,
    },
    Bool(bool),
    Long(i64),
    String(SmolStr),
    Set(Vec<CedarValueJson>),
    Record(JsonRecord),
}
Expand description

The canonical JSON representation of a Cedar value. Many Cedar values have a natural one-to-one mapping to and from JSON values. Cedar values of some types, like entity references or extension values, cannot easily be represented in JSON and thus are represented using the __entity, or __extn escapes.

For example, this is the JSON format for attribute values expected by EntityJsonParser, when schema-based parsing is not used.

Variants§

§

ExprEscape

Fields

§__expr: SmolStr

Contents, will be ignored and an error is thrown when attempting to parse this

The __expr escape has been removed, but is still reserved in order to throw meaningful errors.

§

EntityEscape

Fields

§__entity: TypeAndId

JSON object containing the entity type and ID

Special JSON object with single reserved “__entity” key: the following item should be a JSON object of the form { "type": "xxx", "id": "yyy" }. This escape is necessary for entity references.

§

ExtnEscape

Fields

§__extn: FnAndArg

JSON object containing the extension-constructor call

Special JSON object with single reserved “__extn” key: the following item should be a JSON object of the form { "fn": "xxx", "arg": "yyy" }. This escape is necessary for extension values.

§

Bool(bool)

JSON bool => Cedar bool

§

Long(i64)

JSON int => Cedar long (64-bit signed integer)

§

String(SmolStr)

JSON string => Cedar string

§

Set(Vec<CedarValueJson>)

JSON list => Cedar set; can contain any CedarValueJsons, even heterogeneously

§

Record(JsonRecord)

JSON object => Cedar record; must have string keys, but values can be any CedarValueJsons, even heterogeneously

Implementations§

source§

impl CedarValueJson

source

pub fn uid(euid: &EntityUID) -> Self

Encode the given EntityUID as a CedarValueJson

source

pub fn into_expr( self, ctx: impl Fn() -> JsonDeserializationErrorContext + Clone ) -> Result<RestrictedExpr, JsonDeserializationError>

Convert this CedarValueJson into a Cedar “restricted expression”

source

pub fn from_expr( expr: BorrowedRestrictedExpr<'_> ) -> Result<Self, JsonSerializationError>

Convert a Cedar “restricted expression” into a CedarValueJson.

source

pub fn from_value(value: Value) -> Result<Self, JsonSerializationError>

Convert a Cedar value into a CedarValueJson.

Only throws errors in two cases:

  1. value is (or contains) a record with a reserved key such as “__entity”
  2. value is (or contains) an extension value, and the argument to the extension constructor that produced that extension value can’t itself be converted to CedarJsonValue. (Either because that argument falls into one of these two cases itself, or because the argument is a nontrivial residual.)
source

pub fn from_valuekind(value: ValueKind) -> Result<Self, JsonSerializationError>

Convert a Cedar ValueKind into a CedarValueJson.

For discussion of when this throws errors, see notes on from_value.

source

pub fn from_lit(lit: Literal) -> Self

Convert a Cedar literal into a CedarValueJson.

Trait Implementations§

source§

impl Clone for CedarValueJson

source§

fn clone(&self) -> CedarValueJson

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CedarValueJson

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for CedarValueJson

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for CedarValueJson

source§

fn eq(&self, other: &CedarValueJson) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for CedarValueJson

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for CedarValueJson

source§

impl StructuralPartialEq for CedarValueJson

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> 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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,