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
The __expr
escape has been removed, but is still reserved in order to throw meaningful errors.
EntityEscape
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
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 CedarValueJson
s, even
heterogeneously
Record(JsonRecord)
JSON object => Cedar record; must have string keys, but values
can be any CedarValueJson
s, even heterogeneously
Implementations§
source§impl CedarValueJson
impl CedarValueJson
sourcepub fn into_expr(
self,
ctx: impl Fn() -> JsonDeserializationErrorContext + Clone
) -> Result<RestrictedExpr, JsonDeserializationError>
pub fn into_expr( self, ctx: impl Fn() -> JsonDeserializationErrorContext + Clone ) -> Result<RestrictedExpr, JsonDeserializationError>
Convert this CedarValueJson
into a Cedar “restricted expression”
sourcepub fn from_expr(
expr: BorrowedRestrictedExpr<'_>
) -> Result<Self, JsonSerializationError>
pub fn from_expr( expr: BorrowedRestrictedExpr<'_> ) -> Result<Self, JsonSerializationError>
Convert a Cedar “restricted expression” into a CedarValueJson
.
sourcepub fn from_value(value: Value) -> Result<Self, JsonSerializationError>
pub fn from_value(value: Value) -> Result<Self, JsonSerializationError>
Convert a Cedar value into a CedarValueJson
.
Only throws errors in two cases:
value
is (or contains) a record with a reserved key such as “__entity”value
is (or contains) an extension value, and the argument to the extension constructor that produced that extension value can’t itself be converted toCedarJsonValue
. (Either because that argument falls into one of these two cases itself, or because the argument is a nontrivial residual.)
Trait Implementations§
source§impl Clone for CedarValueJson
impl Clone for CedarValueJson
source§fn clone(&self) -> CedarValueJson
fn clone(&self) -> CedarValueJson
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CedarValueJson
impl Debug for CedarValueJson
source§impl<'de> Deserialize<'de> for CedarValueJson
impl<'de> Deserialize<'de> for CedarValueJson
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>,
source§impl PartialEq for CedarValueJson
impl PartialEq for CedarValueJson
source§fn eq(&self, other: &CedarValueJson) -> bool
fn eq(&self, other: &CedarValueJson) -> bool
self
and other
values to be equal, and is used
by ==
.