use std::default::Default;
use std::collections::HashMap;
use num_traits::{Float,Unsigned};
use serde_derive::{Serialize,Deserialize};
use serde::ser;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
pub struct Product<T, U> where T: Unsigned, U: Float {
pub quantity: T,
pub weight: U, #[serde(flatten)]
pub dimensions: Dimensions<U>,
pub description: String,
pub id: Option<u32>, }
impl<T, U> Product<T, U>
where T: Unsigned + ser::Serialize + Default, U: Float + ser::Serialize + Default {
pub fn new() -> Self {
Default::default()
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
pub struct Dimensions<T> where T: Float {
pub length: T,
pub width: T,
pub height: T,
}
impl<T> Dimensions<T> where T: Float + Default {
pub fn new() -> Self {
Default::default()
}
pub fn from_lwh(length: T, width: T, height: T) -> Self {
Dimensions {
length,
width,
height,
}
}
}
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Service<T> where T: Float {
pub total: T,
pub price_insurance_ex: T,
pub fee: T,
pub insured_amount: T,
pub service: String,
pub transit_time: String,
pub pickup_dates: Vec<String>,
pub pickup_time: HashMap<String, String>,
}