Individual

Struct Individual 

Source
pub struct Individual {
Show 19 fields pub id: Option<String>, pub href: Option<String>, pub aristocratic_title: Option<String>, pub birth_date: Option<DateTime>, pub full_name: Option<String>, pub gender: Option<String>, pub generation: Option<String>, pub given_name: Option<String>, pub legal_name: Option<String>, pub location: Option<String>, pub marital_status: Option<String>, pub middle_name: Option<String>, pub nationality: Option<String>, pub place_of_birth: Option<String>, pub preferred_given_name: Option<String>, pub title: Option<String>, pub contact_medium: Option<Vec<ContactMedium>>, pub related_party: Option<Vec<RelatedParty>>, pub party_characteristic: Option<Vec<Characteristic>>, /* private fields */
}
Expand description

An individual

Fields§

§id: Option<String>

Unique id for this individual

§href: Option<String>

HTML reference for this individual object

§aristocratic_title: Option<String>

Aristocratic Title, e.g. Lord, Lady, Count

§birth_date: Option<DateTime>

Date of Birth

§full_name: Option<String>

Full name of the individual

§gender: Option<String>

Gender

§generation: Option<String>

Generation

§given_name: Option<String>

Given Name

§legal_name: Option<String>

Legal Name

§location: Option<String>

Location

§marital_status: Option<String>

Marital Status

§middle_name: Option<String>

Middle Name

§nationality: Option<String>

Nationality

§place_of_birth: Option<String>

Birth Place

§preferred_given_name: Option<String>

Preferred Given Name

§title: Option<String>

Title, e.g.Mr, Mrs etc

§contact_medium: Option<Vec<ContactMedium>>

Methods for contacting this individual

§related_party: Option<Vec<RelatedParty>>

Parties related to this individual, e.g. company / organization

§party_characteristic: Option<Vec<Characteristic>>

Party Characteristics

Implementations§

Source§

impl Individual

Source

pub fn new(name: impl Into<String>) -> Individual

Create a new instance of indiviudal object

Examples found in repository?
examples/create_individual_event.rs (line 10)
9fn main() {
10    let individual = Individual::new("John Quincy Smith");
11
12    let event = individual.to_event(IndividualEventType::IndividualCreateEvent);
13
14    dbg!(event);
15}
More examples
Hide additional examples
examples/create_individual.rs (line 9)
8fn main() {
9    let individual = Individual::new("John Bagford Smith")
10        .email("john.smith@example.com")
11        .mobile("0411 111 111")
12        .title("Mr")
13        .preferred("Baggie");
14
15    dbg!(individual);
16}
examples/create_permission.rs (line 16)
13fn main() {
14    #[cfg(all(feature = "tmf672", feature = "build-V4"))]
15    {
16        let user = Individual::new("A User");
17        let perm = Permission::new(RelatedParty::from(&user)).desc("A Description");
18
19        dbg!(perm);
20    }
21}
examples/create_party_role.rs (line 21)
20fn main() {
21    let individual = Individual::new("John Smith");
22    let organisation = Organization::new("A Customer".to_string());
23    let customer = Customer::new(organisation);
24    let mut role = PartyRole::new("Account Manager", RelatedParty::from(&individual));
25    role.add_party(RelatedParty::from(&customer));
26    dbg!(role);
27}
examples/convert_to_ref.rs (line 14)
10fn main() {
11    // Create a value of type i32
12    let cat = Category::new("Example Category");
13    let catalog = Catalog::new("Example Catalog");
14    let individual = Individual::new("Example Individual");
15
16    let cat_ref = cat.as_ref();
17    let catalog_ref = catalog.as_ref();
18    let individual_ref = individual.as_ref();
19
20    dbg!(cat_ref);
21    dbg!(catalog_ref);
22    dbg!(individual_ref);
23}
examples/create_message.rs (line 15)
12fn main() {
13    #[cfg(all(feature = "tmf681", feature = "build-V4"))]
14    {
15        let from = Individual::new("John Smith");
16        let to1 = Individual::new("Suzy Citizen");
17        let to2 = Individual::new("Ryan Ruckley").email("rruckley@gmail.com");
18
19        let message = CommunicationMessage::email("A Subject", "Some Content")
20            .from(&from)
21            .to(vec![&to1, &to2]);
22
23        dbg!(message);
24    }
25}
Source

pub fn email(self, email: &str) -> Individual

Convenience function to add an email contact medium

§Example
use tmflib::tmf632::individual_v4::Individual;

let individual = Individual::new("John Smith")
    .email("john.smith@example.com");
Examples found in repository?
examples/create_individual.rs (line 10)
8fn main() {
9    let individual = Individual::new("John Bagford Smith")
10        .email("john.smith@example.com")
11        .mobile("0411 111 111")
12        .title("Mr")
13        .preferred("Baggie");
14
15    dbg!(individual);
16}
More examples
Hide additional examples
examples/create_message.rs (line 17)
12fn main() {
13    #[cfg(all(feature = "tmf681", feature = "build-V4"))]
14    {
15        let from = Individual::new("John Smith");
16        let to1 = Individual::new("Suzy Citizen");
17        let to2 = Individual::new("Ryan Ruckley").email("rruckley@gmail.com");
18
19        let message = CommunicationMessage::email("A Subject", "Some Content")
20            .from(&from)
21            .to(vec![&to1, &to2]);
22
23        dbg!(message);
24    }
25}
examples/create_shopping_cart.rs (line 28)
21fn main() {
22    #[cfg(all(feature = "tmf663", feature = "build-V4"))]
23    {
24        let mut cart = ShoppingCart::new();
25        let offer = ProductOffering::new("MyProductOffer");
26        let por = ProductOfferingRef::from(offer);
27        let individual = Individual::new("John Smith")
28            .email("john.smith@example.com")
29            .mobile("0411 111 111");
30        let note1 = Note::from("Checking on stock levels");
31
32        let mut item = CartItem::from(por);
33        item.add_note(note1);
34        cart.add_item(item);
35        cart.add_party(RelatedParty::from(&individual));
36
37        dbg!(cart);
38    }
39}
examples/cart_to_order.rs (line 32)
26fn main() {
27    #[cfg(all(feature = "tmf663", feature = "build-V4"))]
28    {
29        let mut cart = ShoppingCart::new();
30        let offer = ProductOffering::new("MyProductOffer");
31        let individual = Individual::new("John Smith")
32            .email("john.smith@example.com")
33            .mobile("0411 111 111");
34        let note1 = Note::from("Checking on stock levels");
35
36        let mut item = CartItem::from(ProductOfferingRef::from(offer));
37        item.add_note(note1);
38        item.quantity = 11;
39        cart.add_item(item);
40        cart.add_party(RelatedParty::from(&individual));
41
42        let order = ProductOrder::from(cart);
43
44        dbg!(order);
45    }
46}
Source

pub fn title(self, title: impl Into<String>) -> Individual

Convenience function to set the title for an individual

§Example
use tmflib::tmf632::individual_v4::Individual;

let individual = Individual::new("John Smith")
    .title("Mr");
Examples found in repository?
examples/create_individual.rs (line 12)
8fn main() {
9    let individual = Individual::new("John Bagford Smith")
10        .email("john.smith@example.com")
11        .mobile("0411 111 111")
12        .title("Mr")
13        .preferred("Baggie");
14
15    dbg!(individual);
16}
Source

pub fn gender(self, gender: impl Into<String>) -> Individual

Convenience function to set the gender for an individual

§Example
use tmflib::tmf632::individual_v4::Individual;

let individual = Individual::new("John Smith")
    .gender("Unspecified");
Source

pub fn preferred(self, preferred: impl Into<String>) -> Individual

Convenience function to set the preferred given name for an individual

§Example
use tmflib::tmf632::individual_v4::Individual;

let individual = Individual::new("John Smith")
    .gender("Unspecified");
Examples found in repository?
examples/create_individual.rs (line 13)
8fn main() {
9    let individual = Individual::new("John Bagford Smith")
10        .email("john.smith@example.com")
11        .mobile("0411 111 111")
12        .title("Mr")
13        .preferred("Baggie");
14
15    dbg!(individual);
16}
Source

pub fn mobile(self, mobile: &str) -> Individual

Convenience funciton to add a mobile number contact medium

§Example
use tmflib::tmf632::individual_v4::Individual;

let individual = Individual::new("John Smith")
    .mobile("0411 111 111");
Examples found in repository?
examples/create_individual.rs (line 11)
8fn main() {
9    let individual = Individual::new("John Bagford Smith")
10        .email("john.smith@example.com")
11        .mobile("0411 111 111")
12        .title("Mr")
13        .preferred("Baggie");
14
15    dbg!(individual);
16}
More examples
Hide additional examples
examples/create_shopping_cart.rs (line 29)
21fn main() {
22    #[cfg(all(feature = "tmf663", feature = "build-V4"))]
23    {
24        let mut cart = ShoppingCart::new();
25        let offer = ProductOffering::new("MyProductOffer");
26        let por = ProductOfferingRef::from(offer);
27        let individual = Individual::new("John Smith")
28            .email("john.smith@example.com")
29            .mobile("0411 111 111");
30        let note1 = Note::from("Checking on stock levels");
31
32        let mut item = CartItem::from(por);
33        item.add_note(note1);
34        cart.add_item(item);
35        cart.add_party(RelatedParty::from(&individual));
36
37        dbg!(cart);
38    }
39}
examples/cart_to_order.rs (line 33)
26fn main() {
27    #[cfg(all(feature = "tmf663", feature = "build-V4"))]
28    {
29        let mut cart = ShoppingCart::new();
30        let offer = ProductOffering::new("MyProductOffer");
31        let individual = Individual::new("John Smith")
32            .email("john.smith@example.com")
33            .mobile("0411 111 111");
34        let note1 = Note::from("Checking on stock levels");
35
36        let mut item = CartItem::from(ProductOfferingRef::from(offer));
37        item.add_note(note1);
38        item.quantity = 11;
39        cart.add_item(item);
40        cart.add_party(RelatedParty::from(&individual));
41
42        let order = ProductOrder::from(cart);
43
44        dbg!(order);
45    }
46}
Source

pub fn add_contact(&mut self, medium: ContactMedium)

Add a contact medium to the individual

Examples found in repository?
examples/create_product_order.rs (line 36)
28fn main() {
29    #[cfg(all(feature = "tmf622", feature = "build-V4"))]
30    {
31        // This example simple creates in memory structures without reference to any persistence
32        let offer = ProductOffering::new("Sample Offering");
33        let org = Organization::new("ACustomer");
34        let customer = Customer::new(org);
35        let mut person = Individual::new("John Smith");
36        person.add_contact(ContactMedium::email("John.Smith@example.com"));
37        let mut order = ProductOrder::new();
38        order.add_order_item(ProductOrderItem::from(offer));
39        order.add_party(RelatedParty::from(&customer));
40        order.add_party(RelatedParty::from(&person));
41        dbg!(order);
42    }
43}
Source

pub fn get_mobile(&self) -> Option<String>

Get Mobile number from contact medium if present

Source

pub fn get_email(&self) -> Option<String>

Get Email address from contact medium if present

Source

pub fn replace_characteristic( &mut self, characteristic: Characteristic, ) -> Option<Characteristic>

Replace a characteristic returning the old value if found

Source

pub fn generate_code(&mut self, offset: Option<u32>)

Generate a new site code based on available fields

Trait Implementations§

Source§

impl Clone for Individual

Source§

fn clone(&self) -> Individual

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Individual

Source§

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

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

impl Default for Individual

Source§

fn default() -> Individual

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Individual

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl EventPayload<IndividualEvent> for Individual

Source§

type Subject = Individual

Object the event pertains to
Source§

type EventType = IndividualEventType

Type of event generated
Source§

fn to_event( &self, event_type: Self::EventType, ) -> Event<IndividualEvent, Self::EventType>

Convert the item into an event
Source§

impl From<&Individual> for Contact

Source§

fn from(value: &Individual) -> Self

Converts to this type from the input type.
Source§

impl From<&Individual> for Receiver

Source§

fn from(value: &Individual) -> Self

Converts to this type from the input type.
Source§

impl From<&Individual> for RelatedParty

Source§

fn from(value: &Individual) -> Self

Converts to this type from the input type.
Source§

impl From<&Individual> for Sender

Source§

fn from(value: &Individual) -> Self

Converts to this type from the input type.
Source§

impl HasId for Individual

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. Read more
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]
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. Read more
Source§

impl HasName for Individual

Source§

fn get_name(&self) -> String

Return name of object
Source§

fn set_name(&mut self, name: impl Into<String>)

Set the name, trimming any whitespace
Source§

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

Builder pattern to set name on create, usually coverered by new()
Source§

fn find(&self, pattern: &str) -> bool

Match against the name
Source§

fn as_entity(&self) -> EntityRef

Return a EntityRef for this object
Source§

impl HasReference for Individual

Source§

type RefType = RelatedParty

Reference type assocaited with Self.
Source§

fn as_ref(&self) -> Option<Self::RefType>

Return a reference version of an object, if none exists, return None.
Source§

fn as_entity_ref(&self) -> RelatedEntity

Get object as an EntityRef
Source§

impl HasRelatedParty for Individual

Source§

fn add_party(&mut self, party: RelatedParty)

Add a new party
Source§

fn get_party(&self, idx: usize) -> Option<&RelatedParty>

Get a specific party by index
Source§

fn remove_party(&mut self, idx: usize) -> Result<RelatedParty, TMFError>

Remote a party
Source§

fn get_by_role(&self, role: String) -> Option<Vec<&RelatedParty>>

Get a list of RelatedParty entries by role
Source§

fn party(self, party: RelatedParty) -> Self

Builder pattern to add a party on create
Source§

impl Serialize for Individual

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
Source§

impl TMFEvent<IndividualEvent> for Individual

Source§

fn event(&self) -> IndividualEvent

Geneate container for an TMF payload to be used in an event

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,