Skip to main content

HasEntity

Trait HasEntity 

Source
pub trait HasEntity: Default {
    // Required methods
    fn generate_id(&mut self);
    fn generate_href(&mut self);
    fn get_id(&self) -> String;
    fn get_href(&self) -> String;
    fn get_class() -> String;
    fn get_class_href() -> String;
    fn get_mod_path() -> String;
    fn set_id(&mut self, id: impl Into<String>);
    fn id(self, id: impl Into<String>) -> Self;

    // Provided methods
    fn get_uuid() -> String { ... }
    fn get_full_href(&self, hostname: impl Into<String>) -> String { ... }
    fn create() -> Self { ... }
}
Expand description

Trait indicating a TMF struct has and id, href fields defined in an Entity struct

Required Methods§

Source

fn generate_id(&mut self)

Generate and store a new ID. This will also regenerated the HREF field via generate_href()

Source

fn generate_href(&mut self)

Generate a new HTML reference.

§Details

This is usually triggered directly from generate_id() but can be manually triggered.

Source

fn get_id(&self) -> String

Extract the id of this object into a new String

Source

fn get_href(&self) -> String

Extract the HREF of this object into a new String

Source

fn get_class() -> String

Get the class of this object. This is also used to form part of the URL via generate_href()

Source

fn get_class_href() -> String

Get Class HREF, this represents the generate path to the class.

Source

fn get_mod_path() -> String

Get the module path

Source

fn set_id(&mut self, id: impl Into<String>)

Set the id on the object, also triggers generate_href().

Source

fn id(self, id: impl Into<String>) -> Self

Builder pattern to set id on create() NB: This can be used to set an explicit id on create instead of auto-generate via [create]

Provided Methods§

Source

fn get_uuid() -> String

Get a new UUID in simple format (no seperators)

Source

fn get_full_href(&self, hostname: impl Into<String>) -> String

Generate a complete URL for a given hostname

Source

fn create() -> Self

Create a new instance of a TMF object that has id and href fields.

§Example
let offering = Customer::create();
Examples found in repository?
examples/create_performance.rs (line 8)
7fn main() {
8    let perf = PerformanceMeasurement::create().description("Example Performance Measurement");
9
10    dbg!(perf);
11}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§