pub enum CedarValueJson {
ExprEscape {
__expr: SmolStr,
},
EntityEscape {
__entity: TypeAndId,
},
ExtnEscape {
__extn: FnAndArg,
},
Bool(bool),
Long(i64),
String(SmolStr),
Set(Vec<CedarValueJson>),
Record(JsonRecord),
Null,
}
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
The __expr
escape has been removed, but is still reserved in order to throw meaningful errors.
Fields
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
Null
JSON null, which is never valid, but we put this here in order to provide a better error message.
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.)
Sourcepub fn from_valuekind(value: ValueKind) -> Result<Self, JsonSerializationError>
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
.
Sourcepub fn sub_entity_literals(
self,
mapping: &BTreeMap<EntityUID, EntityUID>,
) -> Result<Self, JsonDeserializationError>
pub fn sub_entity_literals( self, mapping: &BTreeMap<EntityUID, EntityUID>, ) -> Result<Self, JsonDeserializationError>
Substitute entity literals
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§impl Serialize for CedarValueJson
impl Serialize for CedarValueJson
impl Eq for CedarValueJson
impl StructuralPartialEq for CedarValueJson
Auto Trait Implementations§
impl Freeze for CedarValueJson
impl RefUnwindSafe for CedarValueJson
impl Send for CedarValueJson
impl Sync for CedarValueJson
impl Unpin for CedarValueJson
impl UnwindSafe for CedarValueJson
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