pub struct EmailAddress {
pub id: String,
pub created_dtm: i64,
pub modified_dtm: i64,
pub category: String,
pub address: String,
}
Fields§
§id: String
§created_dtm: i64
§modified_dtm: i64
§category: String
§address: String
Implementations§
Source§impl EmailAddress
impl EmailAddress
Sourcepub fn new(category: String, address: String) -> Self
pub fn new(category: String, address: String) -> Self
This is the constructor function.
#Example
extern crate scaffolding_core;
use scaffolding_core::*;
fn main() {
let email = EmailAddress::new(
"home".to_string(),
"myemail@example.com".to_string(),
);
// scaffolding attributes
println!("{}", email.id);
println!("{}", email.created_dtm);
println!("{}", email.modified_dtm,);
}
Sourcepub fn deserialized(serialized: &[u8]) -> Result<EmailAddress, DeserializeError>
pub fn deserialized(serialized: &[u8]) -> Result<EmailAddress, DeserializeError>
This function instantiates a EmailAddress from a JSON string.
#Example
extern crate scaffolding_core;
use scaffolding_core::*;
let serialized = r#"{
"id":"2d624160-16b1-49ce-9b90-09a82127d6ac",
"created_dtm":1711833619,
"modified_dtm":1711833619,
"category":"home",
"address":"myemail@example.com"
}"#;
let mut email = EmailAddress::deserialized(&serialized.as_bytes()).unwrap();
assert_eq!(email.created_dtm, 1711833619);
assert_eq!(email.modified_dtm, 1711833619);
assert_eq!(email.category, "home".to_string());
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
This function performs a quick check to see if the email address is properly formatted. NOTE: This is not a validation that the email address is real.
#Example
extern crate scaffolding_core;
use scaffolding_core::*;
let email = EmailAddress::new(
"home".to_string(),
"myemail@example.com".to_string(),
);
assert_eq!(email.is_valid(), true);
Sourcepub fn serialize(&mut self) -> String
pub fn serialize(&mut self) -> String
This function converts the EmailAddress to a serialize JSON string.
#Example
extern crate scaffolding_core;
use scaffolding_core::*;
let mut email = EmailAddress::new(
"home".to_string(),
"myemail@example.com".to_string(),
);
println!("{}", email.serialize());
Trait Implementations§
Source§impl Clone for EmailAddress
impl Clone for EmailAddress
Source§fn clone(&self) -> EmailAddress
fn clone(&self) -> EmailAddress
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for EmailAddress
impl Debug for EmailAddress
Source§impl<'de> Deserialize<'de> for EmailAddress
impl<'de> Deserialize<'de> for EmailAddress
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for EmailAddress
impl RefUnwindSafe for EmailAddress
impl Send for EmailAddress
impl Sync for EmailAddress
impl Unpin for EmailAddress
impl UnwindSafe for EmailAddress
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more