pub struct EntityBuilder { /* private fields */ }
Expand description

A builder of Entities.

Implementations

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(),
);

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(),
);

Add a class to the Entity

Examples
let entity: Entity = Entity::builder()
    .class("item").into();
 
assert_eq!(&Some(vec!["item".to_string()]), entity.classes());

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());

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());

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());

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());

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(),
);

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(),
);

Add a Property to the Entity.

Examples
let entity: Entity = Entity::builder()
    .property("customerId", "pj123")
    .property("name", "Peter Joseph")
    .into();

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();

Add a vector of Rels for the Entity.

Examples
let entity: Entity = Entity::builder()
    .rel(vec!["http://x.io/rels/customer"]).into();
 
assert_eq!(&Some(vec!["http://x.io/rels/customer".to_string()]), entity.rel());

Set the Entity’s title.

Examples
let entity: Entity = Entity::builder()
    .title("example").into();
 
assert_eq!(&Some("example".to_string()), entity.title());

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.