pub struct Attributes { /* private fields */ }Expand description
An object under construction, with the conditionals a resource needs.
The point of when is the key that is absent, not null. A client told
"permissions": null has to decide what null means; a client not told
about permissions at all knows it is not allowed to see them.
Implementations§
Source§impl Attributes
impl Attributes
pub fn set(self, key: &str, value: impl Into<Json>) -> Self
Sourcepub fn when(
self,
condition: bool,
key: &str,
value: impl FnOnce() -> Json,
) -> Self
pub fn when( self, condition: bool, key: &str, value: impl FnOnce() -> Json, ) -> Self
Include the key only when the condition holds. The value is computed lazily, so it may be expensive or may only be valid when the condition is true.
Sourcepub fn when_some<T: Into<Json>>(self, key: &str, value: Option<T>) -> Self
pub fn when_some<T: Into<Json>>(self, key: &str, value: Option<T>) -> Self
Include the key only when there is a value — Some, not None.
Sourcepub fn merge(self, other: Json) -> Self
pub fn merge(self, other: Json) -> Self
Merge another object’s keys in — for a nested resource, or a shared set of timestamps.
pub fn finish(self) -> Json
Trait Implementations§
Source§impl Clone for Attributes
impl Clone for Attributes
Source§impl Debug for Attributes
impl Debug for Attributes
Auto Trait Implementations§
impl Freeze for Attributes
impl RefUnwindSafe for Attributes
impl Send for Attributes
impl Sync for Attributes
impl Unpin for Attributes
impl UnsafeUnpin for Attributes
impl UnwindSafe for Attributes
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
Mutably borrows from an owned value. Read more