diff --git a/Cargo.lock b/Cargo.lock index 26f9659..19befa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1872,6 +1872,14 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "i18n-files" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -3582,9 +3590,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52" +checksum = "a07e33e919ebcd69113d5be0e4d70c5707004ff45188910106854f38b960df4a" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 57dc606..825275b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ members = [ "actors/search_manager", "actors/token_manager", "actors/fs_manager", - "db-seed" + "db-seed", + "derive/i18n-files" ] [profile.release] diff --git a/derive/i18n-files/Cargo.toml b/derive/i18n-files/Cargo.toml new file mode 100644 index 0000000..50ad7a7 --- /dev/null +++ b/derive/i18n-files/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "i18n-files" +version = "0.1.0" +edition = "2021" + +[lib] +proc-macro = true + +[dependencies] +proc-macro2 = { version = "1.0.38" } +syn = { version = "1.0.94" } diff --git a/derive/i18n-files/src/lib.rs b/derive/i18n-files/src/lib.rs new file mode 100644 index 0000000..cdf6486 --- /dev/null +++ b/derive/i18n-files/src/lib.rs @@ -0,0 +1,7 @@ +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro] +pub fn lang(_item: TokenStream) -> TokenStream { + "fn answer() -> u32 { 42 }".parse().unwrap() +} diff --git a/shared/model/src/api.rs b/shared/model/src/api.rs index 19d8571..4402721 100644 --- a/shared/model/src/api.rs +++ b/shared/model/src/api.rs @@ -16,6 +16,8 @@ pub struct Config { pub pay_methods: Vec, pub coupons: bool, pub currency: String, + pub shipping: bool, + pub shipping_methods: Vec, } #[cfg_attr(feature = "dummy", derive(fake::Dummy))] diff --git a/shared/model/src/lib.rs b/shared/model/src/lib.rs index 4273d84..f4e6717 100644 --- a/shared/model/src/lib.rs +++ b/shared/model/src/lib.rs @@ -397,7 +397,7 @@ impl<'de> serde::Deserialize<'de> for Email { #[serde(transparent)] pub struct NonNegative(i32); -impl std::ops::Add for NonNegative { +impl ops::Add for NonNegative { type Output = Self; fn add(self, rhs: Self) -> Self::Output { @@ -405,7 +405,7 @@ impl std::ops::Add for NonNegative { } } -impl std::ops::Sub for NonNegative { +impl ops::Sub for NonNegative { type Output = Self; fn sub(self, rhs: Self) -> Self::Output { @@ -557,7 +557,7 @@ impl TryFrom for Day { #[serde(transparent)] pub struct Days(Vec); -impl std::ops::Deref for Days { +impl ops::Deref for Days { type Target = Vec; fn deref(&self) -> &Self::Target { @@ -591,12 +591,7 @@ where { fn decode( value: >::ValueRef, - ) -> ::std::result::Result< - Self, - ::std::boxed::Box< - dyn ::std::error::Error + 'static + ::std::marker::Send + ::std::marker::Sync, - >, - > { + ) -> Result> { let value = >::decode(value)?; Ok(Days( (0..7) @@ -1102,3 +1097,12 @@ pub struct ProductPhoto { pub product_id: ProductId, pub photo_id: PhotoId, } + +#[cfg_attr(feature = "dummy", derive(fake::Dummy))] +#[cfg_attr(feature = "db", derive(sqlx::FromRow))] +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "snake_case")] +pub enum ShippingMethod { + InPost, + Custom(String), +}