pub struct Address {
pub id: String,
pub created_dtm: i64,
pub modified_dtm: i64,
pub category: String,
pub line_1: String,
pub line_2: String,
pub line_3: String,
pub line_4: String,
pub country_code: String,
}
Fields§
§id: String
§created_dtm: i64
§modified_dtm: i64
§category: String
§line_1: String
§line_2: String
§line_3: String
§line_4: String
§country_code: String
Implementations§
Source§impl Address
impl Address
Sourcepub fn new(
category: String,
line_1: String,
line_2: String,
line_3: String,
line_4: String,
country_code: String,
) -> Self
pub fn new( category: String, line_1: String, line_2: String, line_3: String, line_4: String, country_code: String, ) -> Self
This is the constructor function.
#Example
extern crate scaffolding_core;
use scaffolding_core::*;
fn main() {
let address = Address::new(
"shipping".to_string(),
"acmes company".to_string(),
"14 Main Street".to_string(),
"Big City, NY 038845".to_string(),
"USA".to_string(),
"USA".to_string(),
);
// scaffolding attributes
println!("{}", address.id);
println!("{}", address.created_dtm);
println!("{}", address.modified_dtm,);
}
Sourcepub fn deserialized(serialized: &[u8]) -> Result<Address, DeserializeError>
pub fn deserialized(serialized: &[u8]) -> Result<Address, DeserializeError>
This function instantiates an Address from a JSON string.
#Example
use scaffolding_core::*;
let serialized = r#"{
"id":"2d624160-16b1-49ce-9b90-09a82127d6ac",
"created_dtm":1711833619,
"modified_dtm":1711833619,
"category":"shipping",
"line_1":"acmes company",
"line_2":"14 Main Street",
"line_3":"Big City, NY 038845",
"line_4":"United States",
"country_code": "USA"
}"#;
let mut address = Address::deserialized(&serialized.as_bytes()).unwrap();
assert_eq!(address.created_dtm, 1711833619);
assert_eq!(address.modified_dtm, 1711833619);
assert_eq!(address.category, "shipping".to_string());
Sourcepub fn serialize(&mut self) -> String
pub fn serialize(&mut self) -> String
This function converts the Address to a serialize JSON string.
#Example
use scaffolding_core::*;
let mut address = Address::new(
"shipping".to_string(),
"acmes company".to_string(),
"14 Main Street".to_string(),
"Big City, NY 038845".to_string(),
"USA".to_string(),
"USA".to_string()
);
println!("{}", address.serialize());
Sourcepub fn update(
&mut self,
category: String,
line_1: String,
line_2: String,
line_3: String,
line_4: String,
country_code: String,
)
pub fn update( &mut self, category: String, line_1: String, line_2: String, line_3: String, line_4: String, country_code: String, )
This function updates the Address.
#Example
use scaffolding_core::*;
let mut address = Address::new(
"shipping".to_string(),
"acmes company".to_string(),
"14 Main Street".to_string(),
"Big City, NY 038845".to_string(),
"USA".to_string(),
"USA".to_string()
);
address.update(
"billing".to_string(),
"acmes company".to_string(),
"14 Main Street".to_string(),
"Big City, NY 038845".to_string(),
"USA".to_string(),
"USA".to_string());
assert_eq!(address.category, "billing".to_string());
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
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 Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
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