Enum cedar_policy_core::entities::JSONValue

source ·
pub enum JSONValue {
    ExprEscape {
        __expr: SmolStr,
    },
    EntityEscape {
        __entity: TypeAndId,
    },
    ExtnEscape {
        __extn: FnAndArg,
    },
    Bool(bool),
    Long(i64),
    String(SmolStr),
    Set(Vec<JSONValue>),
    Record(HashMap<SmolStr, JSONValue>),
}
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 __expr, __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

Special JSON object with single reserved “__expr” key: interpret the following string as a (restricted) Cedar expression. Some escape (this or the following ones) is necessary for extension values and entity references, but this __expr escape could also be used for any other values.

__expr is deprecated (starting with the 1.2 release) and will be removed in favor of __entity and __extn, which together cover all of the use-cases where __expr would have been necessary.

Fields

§__expr: SmolStr

String to interpret as a (restricted) Cedar expression

§

EntityEscape

Special JSON object with single reserved “__entity” key: the following item should be a JSON object of the form { "type": "xxx", "id": "yyy" }. Some escape (this or __expr, which is deprecated) is necessary for entity references.

Fields

§__entity: TypeAndId

JSON object containing the entity type and ID

§

ExtnEscape

Special JSON object with single reserved “__extn” key: the following item should be a JSON object of the form { "fn": "xxx", "arg": "yyy" }. Some escape (this or __expr, which is deprecated) is necessary for extension values.

Fields

§__extn: FnAndArg

JSON object containing the extension-constructor call

§

Bool(bool)

JSON bool => Cedar bool

§

Long(i64)

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

§

String(SmolStr)

JSON string => Cedar string

§

Set(Vec<JSONValue>)

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

§

Record(HashMap<SmolStr, JSONValue>)

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

Implementations§

source§

impl JSONValue

source

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

Encode the given EntityUID as a JSONValue

source

pub fn into_expr(self) -> Result<RestrictedExpr, JsonDeserializationError>

Convert this JSONValue into a Cedar “restricted expression”

source

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

Convert a Cedar “restricted expression” into a JSONValue.

source

pub fn from_lit(lit: Literal) -> Self

Convert a Cedar literal into a JSONValue.

Trait Implementations§

source§

impl Clone for JSONValue

source§

fn clone(&self) -> JSONValue

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 JSONValue

source§

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

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

impl<'de> Deserialize<'de> for JSONValue

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 JSONValue

source§

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

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

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

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

impl Serialize for JSONValue

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 JSONValue

source§

impl StructuralPartialEq for JSONValue

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> ToOwned for T
where T: Clone,

source§

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

source§

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

source§

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