Struct Address

Source
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

Source

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,);
}
Source

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());
Source

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());
Source

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 Clone for Address

Source§

fn clone(&self) -> Address

Returns a copy 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 Address

Source§

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

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

impl<'de> Deserialize<'de> for Address

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 Serialize for Address

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

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> 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>,