http_halforms

Struct Hal

Source
pub struct Hal {
    pub links: BTreeMap<String, SingleOrMultiple<Link>>,
    pub embedded: BTreeMap<String, SingleOrMultiple<Hal>>,
    pub templates: BTreeMap<String, Template>,
    pub payload: Value,
}
Expand description

Representation of a HAL document.

Fields§

§links: BTreeMap<String, SingleOrMultiple<Link>>§embedded: BTreeMap<String, SingleOrMultiple<Hal>>§templates: BTreeMap<String, Template>§payload: Value

Implementations§

Source§

impl Hal

Source

pub fn new<V>(value: V) -> Self
where V: Serialize,

Create a new HAL document for the given payload value.

§Panics

This will panic if the value provided can not be serialized into JSON for some reason.

Add a new link to a HAL document.

Add a new link to a HAL document.

Source

pub fn with_embedded<N, H>(self, name: N, value: H) -> Self
where N: ToString, H: Into<Hal>,

Add a new embedded HAL document to the HAL document.

Source

pub fn maybe_with_embedded<N, L>(self, name: N, embedded: Option<L>) -> Self
where N: ToString, L: Into<Hal>,

Add a new embedded HAL document to a HAL document.

Source

pub fn with_template<N, T>(self, name: N, value: T) -> Self
where N: ToString, T: Into<Template>,

Add a new action template to the HAL-FORMS document.

Source

pub fn maybe_with_template<N, T>(self, name: N, template: Option<T>) -> Self
where N: ToString, T: Into<Template>,

Add a new action template to the HAL-FORMS document.

Trait Implementations§

Source§

impl Debug for Hal

Source§

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

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

impl Serialize for Hal

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 Hal

§

impl RefUnwindSafe for Hal

§

impl Send for Hal

§

impl Sync for Hal

§

impl Unpin for Hal

§

impl UnwindSafe for Hal

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.