Entity

Struct Entity 

Source
pub struct Entity {
    pub class: Vec<String>,
    pub properties: Value,
    pub entities: Vec<SubEntity>,
    pub links: Vec<NavigationalLink>,
    pub actions: Vec<Action>,
    pub title: Option<String>,
}

Fields§

§class: Vec<String>

Describes the nature of an entity’s content based on the current representation. Possible values are implementation-dependent and should be documented. MUST be an array of strings. Optional.

§properties: Value

A set of key-value pairs that describe the state of an entity. In JSON Siren, this is an object such as { “name”: “Kevin”, “age”: 30 }. Optional.

§entities: Vec<SubEntity>

A collection of related sub-entities. If a sub-entity contains an href value, it should be treated as an embedded link. Clients may choose to optimistically load embedded links. If no href value exists, the sub-entity is an embedded entity representation that contains all the characteristics of a typical entity. One difference is that a sub-entity MUST contain a rel attribute to describe its relationship to the parent entity.

§links: Vec<NavigationalLink>

A collection of items that describe navigational links, distinct from entity relationships. Link items should contain a rel attribute to describe the relationship and an href attribute to point to the target URI. Entities should include a link rel to self. In JSON Siren, this is represented as “links”: [{ "rel": ["self"], "href": "http://api.x.io/orders/1234" }] Optional.

§actions: Vec<Action>

A collection of action objects, represented in JSON Siren as an array such as { “actions”: [{ … }] }. See Actions. Optional

§title: Option<String>

Descriptive text about the entity. Optional.

Implementations§

Source§

impl Entity

Source

pub fn with_properties<S: Serialize>( self, serializable: S, ) -> Result<Self, EntityBuilderError>

Source

pub fn with_class_member(self, class_member: impl Into<String>) -> Self

Source

pub fn with_action(self, action: Action) -> Self

Source

pub fn push_sub_entity(&mut self, sub_entity: SubEntity)

Trait Implementations§

Source§

impl Debug for Entity

Source§

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

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

impl Default for Entity

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Entity

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 Serialize for Entity

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

Auto Trait Implementations§

§

impl Freeze for Entity

§

impl RefUnwindSafe for Entity

§

impl Send for Entity

§

impl Sync for Entity

§

impl Unpin for Entity

§

impl UnwindSafe for Entity

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