Struct vnd_siren::entity::EntityBuilder
source · pub struct EntityBuilder { /* private fields */ }
Expand description
A builder of Entities.
Implementations
sourceimpl EntityBuilder
impl EntityBuilder
sourcepub fn action(self, action: impl Into<Action>) -> Self
pub fn action(self, action: impl Into<Action>) -> Self
Adds and Action to the Entity.
Examples
let entity: Entity = Entity::builder()
.action(
Action::builder("add-item", "http://api.x.io/orders/42/items")
).into();
assert_eq!(
&Some(vec![
Action::builder("add-item", "http://api.x.io/orders/42/items").into(),
]),
entity.actions(),
);
sourcepub fn actions(self, actions: Vec<impl Into<Action>>) -> Self
pub fn actions(self, actions: Vec<impl Into<Action>>) -> Self
Adds a list of Actions to the Entity.
Examples
let entity: Entity = Entity::builder()
.actions(vec![
Action::builder("add-item", "http://api.x.io/orders/42/items"),
]).into();
assert_eq!(
&Some(vec![
Action::builder("add-item", "http://api.x.io/orders/42/items").into(),
]),
entity.actions(),
);
sourcepub fn class(self, class: impl Into<String>) -> Self
pub fn class(self, class: impl Into<String>) -> Self
Add a class to the Entity
Examples
let entity: Entity = Entity::builder()
.class("item").into();
assert_eq!(&Some(vec!["item".to_string()]), entity.classes());
sourcepub fn classes(self, classes: Vec<impl Into<String>>) -> Self
pub fn classes(self, classes: Vec<impl Into<String>>) -> Self
Add a vector of classes to the Entity
Examples
let entity: Entity = Entity::builder()
.classes(vec!["item"]).into();
assert_eq!(&Some(vec!["item".to_string()]), entity.classes());
sourcepub fn entity(self, entity: impl Into<Entity>) -> Self
pub fn entity(self, entity: impl Into<Entity>) -> Self
Add an Entity to the Entity.
Examples
let entity: Entity = Entity::builder()
.entity(Entity::builder()).into();
assert_eq!(&Some(vec![Box::new(Entity::builder().into())]), entity.entities());
sourcepub fn entities(self, entities: Vec<impl Into<Entity>>) -> Self
pub fn entities(self, entities: Vec<impl Into<Entity>>) -> Self
Add a vector of Entities to the Entity.
Examples
let entity: Entity = Entity::builder()
.entities(vec![Entity::builder()]).into();
assert_eq!(&Some(vec![Box::new(Entity::builder().into())]), entity.entities());
sourcepub fn href(self, href: impl Into<String>) -> Self
pub fn href(self, href: impl Into<String>) -> Self
Set the Entity’s href.
Examples
let entity: Entity = Entity::builder()
.href("http://api.x.io/orders/42/items").into();
assert_eq!(&Some("http://api.x.io/orders/42/items".to_string()), entity.href());
sourcepub fn link(self, link: impl Into<Link>) -> Self
pub fn link(self, link: impl Into<Link>) -> Self
Add a Link to the Entity.
Examples
let entity: Entity = Entity::builder()
.link(Link::builder(vec!["self"], "http://api.x.io/customers/pj123"))
.into();
assert_eq!(
&Some(vec![
Link::builder(vec!["self"], "http://api.x.io/customers/pj123").into()
]),
entity.links(),
);
sourcepub fn links(self, links: Vec<impl Into<Link>>) -> Self
pub fn links(self, links: Vec<impl Into<Link>>) -> Self
Add a vector of Links to the Entity.
Examples
let entity: Entity = Entity::builder()
.links(vec![
Link::builder(vec!["self"], "http://api.x.io/customers/pj123")
]).into();
assert_eq!(
&Some(vec![
Link::builder(vec!["self"], "http://api.x.io/customers/pj123").into()
]),
entity.links(),
);
sourcepub fn property(self, key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn property(self, key: impl Into<String>, value: impl Into<Value>) -> Self
Add a Property to the Entity.
Examples
let entity: Entity = Entity::builder()
.property("customerId", "pj123")
.property("name", "Peter Joseph")
.into();
sourcepub fn properties(self, properties: Vec<impl Into<Property>>) -> Self
pub fn properties(self, properties: Vec<impl Into<Property>>) -> Self
Add a vector of Properties to the Entity.
Examples
let entity: Entity = Entity::builder()
.properties(vec![
Property::new("customerId", "pj123"),
Property::new("name", "Peter Joseph"),
]).into();
let entity: Entity = Entity::builder()
.properties(vec![
("customerId", "pj123"),
("name", "Peter Joseph"),
]).into();
Trait Implementations
sourceimpl Clone for EntityBuilder
impl Clone for EntityBuilder
sourcefn clone(&self) -> EntityBuilder
fn clone(&self) -> EntityBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for EntityBuilder
impl Debug for EntityBuilder
sourceimpl From<EntityBuilder> for Entity
impl From<EntityBuilder> for Entity
sourcefn from(builder: EntityBuilder) -> Entity
fn from(builder: EntityBuilder) -> Entity
Converts to this type from the input type.
sourceimpl PartialEq<EntityBuilder> for EntityBuilder
impl PartialEq<EntityBuilder> for EntityBuilder
sourcefn eq(&self, other: &EntityBuilder) -> bool
fn eq(&self, other: &EntityBuilder) -> bool
impl StructuralPartialEq for EntityBuilder
Auto Trait Implementations
impl RefUnwindSafe for EntityBuilder
impl Send for EntityBuilder
impl Sync for EntityBuilder
impl Unpin for EntityBuilder
impl UnwindSafe for EntityBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more