ScaffoldingEmailAddresses

Trait ScaffoldingEmailAddresses 

Source
pub trait ScaffoldingEmailAddresses {
    // Required methods
    fn get_email_address(&self, id: String) -> Option<&EmailAddress>;
    fn insert_email_address(
        &mut self,
        category: String,
        address: String,
    ) -> String;
    fn search_email_addresses_by_category(
        &self,
        category: String,
    ) -> Vec<EmailAddress>;
    fn remove_email_address(&mut self, id: String);
}
Expand description

The email address behavior of a Scaffolding object

Required Methods§

Source

fn get_email_address(&self, id: String) -> Option<&EmailAddress>

Retrieves a related EmailAddress based on the specific id.

#Example

extern crate scaffolding_core;
  
use scaffolding_core::*;

#[scaffolding_struct("email_addresses")]
#[derive(Clone, Debug, Deserialize, Serialize, Scaffolding, ScaffoldingEmailAddresses)]
struct MyEntity {}

impl MyEntity {
    #[scaffolding_fn("email_addresses")]
    fn new() -> Self {
        Self {}
    }
}

let mut entity = MyEntity::new();
let id = entity.insert_email_address(
    "home".to_string(),
    "myemail@example.com".to_string(),
);

assert_eq!(entity.get_email_address(id).unwrap().address, "myemail@example.com".to_string());
Source

fn insert_email_address(&mut self, category: String, address: String) -> String

Adds a related PhoneNumber to the Entity and returns the id for reference.

#Example

extern crate scaffolding_core;
  
use scaffolding_core::*;

#[scaffolding_struct("email_addresses")]
#[derive(Clone, Debug, Deserialize, Serialize, Scaffolding, ScaffoldingEmailAddresses)]
struct MyEntity {}

impl MyEntity {
    #[scaffolding_fn("email_addresses")]
    fn new() -> Self {
        Self {}
    }
}

let mut entity = MyEntity::new();
let _ = entity.insert_email_address(
    "home".to_string(),
    "myemail@example.com".to_string(),
);

assert_eq!(entity.email_addresses.len(), 1);
Source

fn search_email_addresses_by_category( &self, category: String, ) -> Vec<EmailAddress>

Retrieves all the EmailAddress with the specified category.

#Example

extern crate scaffolding_core;
  
use scaffolding_core::*;

#[scaffolding_struct("email_addresses")]
#[derive(Clone, Debug, Deserialize, Serialize, Scaffolding, ScaffoldingEmailAddresses)]
struct MyEntity {}

impl MyEntity {
    #[scaffolding_fn("email_addresses")]
    fn new() -> Self {
        Self {}
    }
}

let mut entity = MyEntity::new();
let _ = entity.insert_email_address(
    "home".to_string(),
    "myemail@example.com".to_string(),
);

assert_eq!(entity.search_email_addresses_by_category("home".to_string()).len(), 1);
Source

fn remove_email_address(&mut self, id: String)

Removes a related EmailAddress to the Entity.

#Example

extern crate scaffolding_core;
  
use scaffolding_core::*;

#[scaffolding_struct("email_addresses")]
#[derive(Clone, Debug, Deserialize, Serialize, Scaffolding, ScaffoldingEmailAddresses)]
struct MyEntity {}

impl MyEntity {
    #[scaffolding_fn("email_addresses")]
    fn new() -> Self {
        Self {}
    }
}

let mut entity = MyEntity::new();
let id = entity.insert_email_address(
    "home".to_string(),
    "myemail@example.com".to_string(),
);
assert_eq!(entity.email_addresses.len(), 1);

entity.remove_email_address(id);
assert_eq!(entity.email_addresses.len(), 0);

Implementors§