diff --git a/Cargo.lock b/Cargo.lock index 124200a24..900e4755f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -197,6 +197,17 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom 0.2.16", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.12" @@ -1496,13 +1507,22 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash 0.7.8", +] + [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash", + "ahash 0.8.12", "allocator-api2", ] @@ -1703,6 +1723,7 @@ checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" dependencies = [ "displaydoc", "litemap", + "serde", "tinystr", "writeable", "zerovec", @@ -2561,6 +2582,7 @@ dependencies = [ "criterion", "dirs", "futures-util", + "icu_locale_core", "insta", "map-macro", "pulldown-cmark", @@ -2571,6 +2593,7 @@ dependencies = [ "reqwest-middleware", "reqwest-retry", "rkyv", + "rkyv_intern", "sea-query", "serde", "serde_json", @@ -3422,6 +3445,15 @@ dependencies = [ "syn 2.0.106", ] +[[package]] +name = "rkyv_intern" +version = "0.1.0" +source = "git+https://github.com/rkyv/rkyv_intern.git#e7b3b5d0b2ef644ce9b0cd4a8141b607c9eaa6de" +dependencies = [ + "hashbrown 0.11.2", + "rkyv", +] + [[package]] name = "rle-decode-fast" version = "1.0.3" @@ -4069,6 +4101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" dependencies = [ "displaydoc", + "serde", "zerovec", ] diff --git a/internal/src/enum_wrapper.rs b/internal/src/enum_wrapper.rs index 97efa7e9b..5ec4f0361 100644 --- a/internal/src/enum_wrapper.rs +++ b/internal/src/enum_wrapper.rs @@ -34,7 +34,7 @@ where #[cfg(test)] mod tests { use super::*; - use odict::schema::{FormKind, PartOfSpeech, PronunciationKind}; + use odict::schema::{FormKind, PartOfSpeech}; #[test] fn test_to_enum_wrapper_pos_custom() { @@ -54,24 +54,6 @@ mod tests { assert_eq!(wrapper.value, "'kari' adjective (archaic)"); } - #[test] - fn test_to_enum_wrapper_pronunciation_kind_custom() { - let wrapper = PronunciationKind::Other("Custom".to_string()).to_enum_wrapper(); - - assert_eq!(wrapper.name, "PronunciationKind"); - assert_eq!(wrapper.variant, "other"); - assert_eq!(wrapper.value, "Custom"); - } - - #[test] - fn test_to_enum_wrapper_pronunciation_kind() { - let wrapper = PronunciationKind::IPA.to_enum_wrapper(); - - assert_eq!(wrapper.name, "PronunciationKind"); - assert_eq!(wrapper.variant, "ipa"); - assert_eq!(wrapper.value, "ipa"); - } - #[test] fn test_to_enum_wrapper_form_kind() { let wrapper = FormKind::Conjugation.to_enum_wrapper(); diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 2e990b009..35ea4f34a 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -77,6 +77,8 @@ reqwest = { version = "0.12.24", optional = true, default-features = false, feat "http2", "stream", ] } +strum = { version = "0.27.2", features = ["derive"] } +icu_locale_core = { version = "2.0.0", features = ["serde"] } reqwest-middleware = { version = "0.4.2", optional = true } reqwest-retry = { version = "0.7.0", optional = true } futures-util = { version = "0.3", optional = true } @@ -87,7 +89,7 @@ tantivy = { version = "0.25.0", optional = true } dirs = { version = "6.0.0", optional = true } # feature=sql sea-query = { version = "0.32.7", optional = true } -strum = { version = "0.27.2", features = ["derive"] } +rkyv_intern = { git = "https://github.com/rkyv/rkyv_intern.git", version = "0.1.0" } [dev-dependencies] criterion = { version = "0.7.0", features = ["async_tokio", "html_reports"] } diff --git a/lib/src/format/json/pronunciation.rs b/lib/src/format/json/pronunciation.rs index fcfecc28a..1c9cc9863 100644 --- a/lib/src/format/json/pronunciation.rs +++ b/lib/src/format/json/pronunciation.rs @@ -1,13 +1,14 @@ +use icu_locale_core::LanguageIdentifier; use serde::Serialize; use structural_convert::StructuralConvert; use super::media_url::MediaURLJSON; -use crate::schema::{Pronunciation, PronunciationKind}; +use crate::schema::Pronunciation; #[derive(Serialize, PartialEq, Eq, StructuralConvert)] #[convert(from(Pronunciation))] pub struct PronunciationJSON { - pub kind: Option, + pub kind: LanguageIdentifier, pub value: String, diff --git a/lib/src/format/md/pronunciation.rs b/lib/src/format/md/pronunciation.rs index 2f1cd3e6e..e62fdaa33 100644 --- a/lib/src/format/md/pronunciation.rs +++ b/lib/src/format/md/pronunciation.rs @@ -5,23 +5,19 @@ pub fn write_pronunciation( pronunciation: &Pronunciation, _entry: &Entry, // Prefix with underscore to indicate intentional non-use ) -> crate::Result<()> { - if let Some(ref kind) = pronunciation.kind { - // Use the kind_str method to get the proper display string (including custom kinds) - let kind_str = kind.to_string(); + // Use the kind_str method to get the proper display string (including custom kinds) + let kind_str = pronunciation.kind.to_string(); - // Capitalize the first letter for display - let kind_display = kind_str - .chars() - .next() - .map(|c| c.to_uppercase().collect::() + &kind_str[1..]) - .unwrap_or_else(|| kind_str.to_string()); + // Capitalize the first letter for display + let kind_display = kind_str + .chars() + .next() + .map(|c| c.to_uppercase().collect::() + &kind_str[1..]) + .unwrap_or_else(|| kind_str.to_string()); - let pron_text = format!("*{}:* {}", kind_display, pronunciation.value); + let pron_text = format!("*{}:* {}", kind_display, pronunciation.value); - lines.push(pron_text); - } else { - lines.push(pronunciation.value.to_string()); - } + lines.push(pron_text); // Add URLs as markdown links if they exist if !pronunciation.media.is_empty() { diff --git a/lib/src/format/sql/pronunciations.rs b/lib/src/format/sql/pronunciations.rs index 86ccb949c..4142b581f 100644 --- a/lib/src/format/sql/pronunciations.rs +++ b/lib/src/format/sql/pronunciations.rs @@ -101,7 +101,7 @@ pub fn insert_pronunciation( ]) .values([ id.as_str().into(), - pronunciation.kind.clone().map(|k| k.to_string()).into(), + pronunciation.kind.to_string().into(), pronunciation.value.clone().into(), etymology_id.into(), ])?, diff --git a/lib/src/lib.rs b/lib/src/lib.rs index b9aecdb49..e66f033b9 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -21,6 +21,7 @@ mod core; mod error; mod ext; mod odict; +mod se; pub mod format; pub mod fs; diff --git a/lib/src/schema/definition.rs b/lib/src/schema/definition.rs index 3e1682d86..f7d96d174 100644 --- a/lib/src/schema/definition.rs +++ b/lib/src/schema/definition.rs @@ -1,4 +1,5 @@ use rkyv::with::{AsBox, MapNiche}; +use rkyv_intern::Intern; use crate::serializable; @@ -13,6 +14,7 @@ serializable! { pub id: Option, #[serde(rename = "@value")] + #[rkyv(with = Intern)] pub value: String, #[serde(default, rename="example")] diff --git a/lib/src/schema/dictionary.rs b/lib/src/schema/dictionary.rs index ae0553a92..3955bdb47 100644 --- a/lib/src/schema/dictionary.rs +++ b/lib/src/schema/dictionary.rs @@ -1,11 +1,12 @@ use rkyv::{ - deserialize, to_bytes, + deserialize, with::{AsBox, MapNiche}, }; + use std::collections::HashSet; use std::str::FromStr; -use crate::{error::Error, serializable}; +use crate::{error::Error, se::serialize_interned, serializable}; use super::{entry::Entry, id::ID}; @@ -66,8 +67,7 @@ impl FromStr for Dictionary { impl Dictionary { pub(crate) fn serialize(&self) -> crate::Result> { - let bytes = - to_bytes::(self).map_err(|e| Error::Serialize(e.to_string()))?; + let bytes = serialize_interned::<_, rkyv::rancor::Error>(self)?; Ok(bytes.to_vec()) } } diff --git a/lib/src/schema/entry.rs b/lib/src/schema/entry.rs index 685f95075..ff2ae85be 100644 --- a/lib/src/schema/entry.rs +++ b/lib/src/schema/entry.rs @@ -1,5 +1,5 @@ use rkyv::{ - deserialize, to_bytes, + deserialize, with::{AsBox, MapNiche}, }; use std::{ @@ -7,7 +7,7 @@ use std::{ hash::{Hash, Hasher}, }; -use crate::{error::Error, schema::Etymology, serializable}; +use crate::{error::Error, schema::Etymology, se::serialize_interned, serializable}; use super::{EntryRef, MediaURL}; @@ -68,9 +68,7 @@ impl Borrow for ArchivedEntry { impl Entry { pub fn serialize(&self) -> crate::Result> { - let bytes = - to_bytes::(self).map_err(|e| Error::Serialize(e.to_string()))?; - + let bytes = serialize_interned::<_, rkyv::rancor::Error>(self)?; Ok(bytes.to_vec()) } } diff --git a/lib/src/schema/enums.rs b/lib/src/schema/enums.rs index 15760cb89..2f9a57f6b 100644 --- a/lib/src/schema/enums.rs +++ b/lib/src/schema/enums.rs @@ -1,6 +1,6 @@ use std::fmt::{Debug, Display}; -use super::{FormKind, PartOfSpeech, PronunciationKind}; +use super::{FormKind, PartOfSpeech}; pub trait EnumIdentifier { fn id(&self) -> String; @@ -30,4 +30,3 @@ macro_rules! impl_enum_identifier { impl_enum_identifier!(PartOfSpeech); impl_enum_identifier!(FormKind); -impl_enum_identifier!(PronunciationKind); diff --git a/lib/src/schema/example.rs b/lib/src/schema/example.rs index 9b3c45024..1aba80f05 100644 --- a/lib/src/schema/example.rs +++ b/lib/src/schema/example.rs @@ -6,6 +6,7 @@ serializable! { #[serde(rename = "example")] pub struct Example { #[serde(rename = "@value")] + #[rkyv(with = rkyv_intern::Intern)] pub value: String, #[serde(default, rename = "translation")] diff --git a/lib/src/schema/group.rs b/lib/src/schema/group.rs index 4d4dd5b5f..cc1fb8bb1 100644 --- a/lib/src/schema/group.rs +++ b/lib/src/schema/group.rs @@ -14,6 +14,7 @@ serializable! { pub id: Option, #[serde(rename = "@description")] + #[rkyv(with = rkyv_intern::Intern)] pub description: String, #[serde(default, rename = "definition")] diff --git a/lib/src/schema/mod.rs b/lib/src/schema/mod.rs index 1447368ab..d986e77ff 100644 --- a/lib/src/schema/mod.rs +++ b/lib/src/schema/mod.rs @@ -14,7 +14,6 @@ mod note; #[allow(non_camel_case_types)] mod pos; mod pronunciation; -mod pronunciation_kind; mod sense; mod translation; @@ -36,6 +35,6 @@ pub use self::media_url::*; pub use self::note::*; pub use self::pos::*; pub use self::pronunciation::*; -pub use self::pronunciation_kind::*; pub use self::sense::*; pub use self::translation::*; +pub use icu_locale_core::LanguageIdentifier; diff --git a/lib/src/schema/note.rs b/lib/src/schema/note.rs index 916857b7d..af2b88510 100644 --- a/lib/src/schema/note.rs +++ b/lib/src/schema/note.rs @@ -17,6 +17,7 @@ serializable! { pub id: Option, #[serde(rename = "@value")] + #[rkyv(with = rkyv_intern::Intern)] pub value: String, } } diff --git a/lib/src/schema/pronunciation.rs b/lib/src/schema/pronunciation.rs index 8f24e61e3..12915290d 100644 --- a/lib/src/schema/pronunciation.rs +++ b/lib/src/schema/pronunciation.rs @@ -1,13 +1,65 @@ -use rkyv::with::{AsBox, MapNiche}; +use icu_locale_core::LanguageIdentifier; +use rkyv::{ + rancor::{Fallible, Source}, + with::{ArchiveWith, DeserializeWith, SerializeWith}, + Archive, Archived, Deserialize, Place, Resolver, Serialize, +}; -use super::{MediaURL, PronunciationKind}; +use super::MediaURL; use crate::serializable; +// Custom wrapper for LanguageIdentifier to serialize as string and deserialize with try_from +pub struct LanguageIdentifierAsString; + +impl ArchiveWith for LanguageIdentifierAsString { + type Archived = Archived; + type Resolver = Resolver; + + fn resolve_with( + field: &LanguageIdentifier, + resolver: Self::Resolver, + out: Place, + ) { + let string_repr = field.to_string(); + string_repr.resolve(resolver, out); + } +} + +impl SerializeWith for LanguageIdentifierAsString +where + String: Serialize, +{ + fn serialize_with( + field: &LanguageIdentifier, + serializer: &mut S, + ) -> Result { + let string_repr = field.to_string(); + string_repr.serialize(serializer) + } +} + +impl DeserializeWith, LanguageIdentifier, D> for LanguageIdentifierAsString +where + D: Fallible + ?Sized, + D::Error: Source, + String: Archive, + Archived: Deserialize, +{ + fn deserialize_with( + field: &Archived, + deserializer: &mut D, + ) -> Result { + let string_repr: String = field.deserialize(deserializer)?; + LanguageIdentifier::try_from_str(string_repr.as_str()) + .map_err(|e| ::new(e)) + } +} + serializable! { pub struct Pronunciation { #[serde(rename = "@kind")] - #[rkyv(with = MapNiche)] - pub kind: Option, + #[rkyv(with = LanguageIdentifierAsString)] + pub kind: LanguageIdentifier, #[serde(rename = "@value")] pub value: String, diff --git a/lib/src/schema/pronunciation_kind.rs b/lib/src/schema/pronunciation_kind.rs deleted file mode 100644 index 841027389..000000000 --- a/lib/src/schema/pronunciation_kind.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::serializable_enum; - -serializable_enum! { - pub enum PronunciationKind { - #[serde(rename = "ipa")] - IPA, - Pinyin, - Hiragana, - Romaji, - Katakana, - Yale, // Korean Yale romanization - Jyutping, // Cantonese - Bopomofo, // Zhuyin for Chinese - Hepburn, // Japanese romanization - #[strum(to_string = "{0}")] - #[serde(untagged)] - Other(String), - } -} diff --git a/lib/src/schema/translation.rs b/lib/src/schema/translation.rs index c0ab58c89..e9975417c 100644 --- a/lib/src/schema/translation.rs +++ b/lib/src/schema/translation.rs @@ -5,9 +5,11 @@ serializable! { #[serde(rename = "translation")] pub struct Translation { #[serde(rename = "@lang")] + #[rkyv(with = rkyv_intern::Intern)] pub lang: String, #[serde(rename = "@value")] + #[rkyv(with = rkyv_intern::Intern)] pub value: String, } } diff --git a/lib/src/se.rs b/lib/src/se.rs new file mode 100644 index 000000000..42af47ab8 --- /dev/null +++ b/lib/src/se.rs @@ -0,0 +1,27 @@ +use rkyv::{ + api::serialize_using, + rancor::Strategy, + ser::{allocator::ArenaHandle, Serializer}, + util::{with_arena, AlignedVec}, + Serialize, +}; +use rkyv_intern::{Interner, InterningAdapter}; + +type InterningSerializer<'a, E> = + Strategy, ArenaHandle<'a>, ()>, Interner>, E>; + +pub fn serialize_interned(value: &T) -> Result, E> +where + T: for<'a> Serialize>, +{ + with_arena(|arena| { + let mut serializer = InterningAdapter::new( + Serializer::new(AlignedVec::<8>::new(), arena.acquire(), ()), + Interner::default(), + ); + + serialize_using::<_, E>(value, &mut serializer)?; + + Ok(serializer.into_serializer().into_writer()) + }) +} diff --git a/lib/tests/pronunciation.rs b/lib/tests/pronunciation.rs index 0ae9ed289..7626fadd1 100644 --- a/lib/tests/pronunciation.rs +++ b/lib/tests/pronunciation.rs @@ -1,24 +1,19 @@ #[cfg(test)] mod pronunciation_tests { - use odict::schema::{MediaURL, PronunciationKind}; + use icu_locale_core::{langid, LanguageIdentifier}; + use odict::schema::MediaURL; use quick_xml::de::from_str; #[test] fn test_pronunciation_kind_serialization() { - let kind = PronunciationKind::IPA; + let kind = langid!("und-fonipa"); let serialized = serde_json::to_string(&kind).unwrap(); - assert_eq!(serialized, "\"ipa\""); - // Test deserialization including case-insensitivity - let deserialized: PronunciationKind = serde_json::from_str("\"ipa\"").unwrap(); + assert_eq!(serialized, "\"und-fonipa\""); - assert!(matches!(deserialized, PronunciationKind::IPA)); + let deserialized: LanguageIdentifier = serde_json::from_str("\"und-fonipa\"").unwrap(); - let _expected = PronunciationKind::Other("wagegiles".into()); - - // Test Other variant - let deserialized: PronunciationKind = serde_json::from_str("\"wadegiles\"").unwrap(); - assert!(matches!(deserialized, _expected)); + assert_eq!(deserialized, kind); } #[test] @@ -45,7 +40,7 @@ mod pronunciation_tests { let xml = r#" - + @@ -59,10 +54,8 @@ mod pronunciation_tests { assert_eq!(entry.etymologies[0].pronunciations.len(), 1); let pronunciation = &entry.etymologies[0].pronunciations[0]; - assert!(matches!( - pronunciation.kind, - Some(PronunciationKind::Pinyin) - )); + + assert_eq!(pronunciation.kind, langid!("zh-Latn-pinyin")); assert_eq!(pronunciation.value, "ni hao"); assert_eq!(pronunciation.media.len(), 1); assert_eq!(pronunciation.media[0].src, "./audio.mp3"); @@ -76,7 +69,7 @@ mod pronunciation_tests { fn test_parse_example_with_pronunciation() { let xml = r#" - + @@ -86,7 +79,7 @@ mod pronunciation_tests { assert_eq!(example.value, "Hello, world!"); assert_eq!(example.pronunciations.len(), 1); let pronunciation = &example.pronunciations[0]; - assert!(matches!(pronunciation.kind, Some(PronunciationKind::IPA))); + assert_eq!(pronunciation.kind, langid!("und-fonipa")); assert_eq!(pronunciation.value, "həˈləʊ wɜːld"); assert_eq!(pronunciation.media.len(), 1); assert_eq!(pronunciation.media[0].src, "./hello.mp3"); @@ -97,10 +90,10 @@ mod pronunciation_tests { let xml = r#" - + - + @@ -113,11 +106,11 @@ mod pronunciation_tests { assert_eq!(entry.etymologies[0].pronunciations.len(), 2); let pinyin = &entry.etymologies[0].pronunciations[0]; - assert!(matches!(pinyin.kind, Some(PronunciationKind::Pinyin))); + assert_eq!(pinyin.kind, langid!("zh-Latn-pinyin")); assert_eq!(pinyin.value, "ni hao"); let ipa = &entry.etymologies[0].pronunciations[1]; - assert!(matches!(ipa.kind, Some(PronunciationKind::IPA))); + assert_eq!(ipa.kind, langid!("und-fonipa")); assert_eq!(ipa.value, "ni˨˩ xɑʊ̯˧˥"); } } diff --git a/node/__test__/pronunciation.spec.ts b/node/__test__/pronunciation.spec.ts index aba5b2180..abf1f13c8 100644 --- a/node/__test__/pronunciation.spec.ts +++ b/node/__test__/pronunciation.spec.ts @@ -6,7 +6,7 @@ test('Pronunciation support - should parse entries with pronunciations', async ( - + @@ -25,9 +25,9 @@ test('Pronunciation support - should parse entries with pronunciations', async ( t.truthy(entry.etymologies[0].pronunciations) t.is(entry.etymologies[0].pronunciations.length, 1) t.deepEqual(entry.etymologies[0].pronunciations[0].kind, { - name: 'PronunciationKind', - value: 'pinyin', - variant: 'pinyin', + language: 'zh', + script: 'Latn', + variants: ['pinyin'], }) t.is(entry.etymologies[0].pronunciations[0].value, 'ni hao') t.is(entry.etymologies[0].pronunciations[0].media.length, 1) @@ -42,7 +42,7 @@ test('Pronunciation support - should parse examples with pronunciations', async - + @@ -65,9 +65,8 @@ test('Pronunciation support - should parse examples with pronunciations', async t.truthy(example.pronunciations) t.is(example.pronunciations.length, 1) t.deepEqual(example.pronunciations[0].kind, { - name: 'PronunciationKind', - value: 'ipa', - variant: 'ipa', + language: 'und', + variants: ['fonipa'], }) t.is(example.pronunciations[0].value, 'ɪɡˈzæmpl ˈsɛntəns') t.is(example.pronunciations[0].media.length, 1) diff --git a/node/index.d.ts b/node/index.d.ts index 66431acf3..42f979722 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -78,6 +78,13 @@ export interface IndexOptions { overwrite?: boolean } +export interface LanguageIdentifier { + language: string + script?: string + region?: string + variants: Array +} + export interface LoadOptions { alias?: AliasLoadOptions } @@ -110,7 +117,7 @@ export interface Note { } export interface Pronunciation { - kind?: EnumWrapper + kind: LanguageIdentifier value: string media: Array } diff --git a/node/index.js b/node/index.js index 76e9659e4..fe0f96fd9 100644 --- a/node/index.js +++ b/node/index.js @@ -80,8 +80,8 @@ function requireNative() { try { const binding = require('@odict/node-android-arm64') const bindingPackageVersion = require('@odict/node-android-arm64/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -96,8 +96,8 @@ function requireNative() { try { const binding = require('@odict/node-android-arm-eabi') const bindingPackageVersion = require('@odict/node-android-arm-eabi/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -117,8 +117,8 @@ function requireNative() { try { const binding = require('@odict/node-win32-x64-gnu') const bindingPackageVersion = require('@odict/node-win32-x64-gnu/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -133,8 +133,8 @@ function requireNative() { try { const binding = require('@odict/node-win32-x64-msvc') const bindingPackageVersion = require('@odict/node-win32-x64-msvc/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -150,8 +150,8 @@ function requireNative() { try { const binding = require('@odict/node-win32-ia32-msvc') const bindingPackageVersion = require('@odict/node-win32-ia32-msvc/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -166,8 +166,8 @@ function requireNative() { try { const binding = require('@odict/node-win32-arm64-msvc') const bindingPackageVersion = require('@odict/node-win32-arm64-msvc/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -185,8 +185,8 @@ function requireNative() { try { const binding = require('@odict/node-darwin-universal') const bindingPackageVersion = require('@odict/node-darwin-universal/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -201,8 +201,8 @@ function requireNative() { try { const binding = require('@odict/node-darwin-x64') const bindingPackageVersion = require('@odict/node-darwin-x64/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -217,8 +217,8 @@ function requireNative() { try { const binding = require('@odict/node-darwin-arm64') const bindingPackageVersion = require('@odict/node-darwin-arm64/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -237,8 +237,8 @@ function requireNative() { try { const binding = require('@odict/node-freebsd-x64') const bindingPackageVersion = require('@odict/node-freebsd-x64/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -253,8 +253,8 @@ function requireNative() { try { const binding = require('@odict/node-freebsd-arm64') const bindingPackageVersion = require('@odict/node-freebsd-arm64/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -274,8 +274,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-x64-musl') const bindingPackageVersion = require('@odict/node-linux-x64-musl/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -290,8 +290,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-x64-gnu') const bindingPackageVersion = require('@odict/node-linux-x64-gnu/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -308,8 +308,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-arm64-musl') const bindingPackageVersion = require('@odict/node-linux-arm64-musl/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -324,8 +324,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-arm64-gnu') const bindingPackageVersion = require('@odict/node-linux-arm64-gnu/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -342,8 +342,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-arm-musleabihf') const bindingPackageVersion = require('@odict/node-linux-arm-musleabihf/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -358,8 +358,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-arm-gnueabihf') const bindingPackageVersion = require('@odict/node-linux-arm-gnueabihf/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -376,8 +376,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-loong64-musl') const bindingPackageVersion = require('@odict/node-linux-loong64-musl/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -392,8 +392,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-loong64-gnu') const bindingPackageVersion = require('@odict/node-linux-loong64-gnu/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -410,8 +410,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-riscv64-musl') const bindingPackageVersion = require('@odict/node-linux-riscv64-musl/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -426,8 +426,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-riscv64-gnu') const bindingPackageVersion = require('@odict/node-linux-riscv64-gnu/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -443,8 +443,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-ppc64-gnu') const bindingPackageVersion = require('@odict/node-linux-ppc64-gnu/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -459,8 +459,8 @@ function requireNative() { try { const binding = require('@odict/node-linux-s390x-gnu') const bindingPackageVersion = require('@odict/node-linux-s390x-gnu/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -479,8 +479,8 @@ function requireNative() { try { const binding = require('@odict/node-openharmony-arm64') const bindingPackageVersion = require('@odict/node-openharmony-arm64/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -495,8 +495,8 @@ function requireNative() { try { const binding = require('@odict/node-openharmony-x64') const bindingPackageVersion = require('@odict/node-openharmony-x64/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { @@ -511,8 +511,8 @@ function requireNative() { try { const binding = require('@odict/node-openharmony-arm') const bindingPackageVersion = require('@odict/node-openharmony-arm/package.json').version - if (bindingPackageVersion !== '1.9.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { - throw new Error(`Native binding package version mismatch, expected 1.9.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + if (bindingPackageVersion !== '2.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) } return binding } catch (e) { diff --git a/node/src/types/langid.rs b/node/src/types/langid.rs new file mode 100644 index 000000000..822a6e7b9 --- /dev/null +++ b/node/src/types/langid.rs @@ -0,0 +1,22 @@ +#[napi(object)] +pub struct LanguageIdentifier { + pub language: String, + pub script: Option, + pub region: Option, + pub variants: Vec, +} + +impl From for LanguageIdentifier { + fn from(language_identifier: odict::schema::LanguageIdentifier) -> Self { + Self { + language: language_identifier.language.to_string(), + script: language_identifier.script.map(|s| s.to_string()), + region: language_identifier.region.map(|r| r.to_string()), + variants: language_identifier + .variants + .into_iter() + .map(|v| v.to_string()) + .collect(), + } + } +} diff --git a/node/src/types/mod.rs b/node/src/types/mod.rs index d3856afd8..6b16b8e93 100644 --- a/node/src/types/mod.rs +++ b/node/src/types/mod.rs @@ -6,6 +6,7 @@ mod example; mod form; mod group; mod index; +mod langid; #[cfg(feature = "node")] mod load; @@ -32,6 +33,7 @@ pub use save::*; pub use entry::Entry; pub use example::Example; pub use index::IndexOptions; +pub use langid::LanguageIdentifier; pub use lookup::{LookupOptions, LookupResult}; pub use pronunciation::Pronunciation; pub use search::SearchOptions; diff --git a/node/src/types/pronunciation.rs b/node/src/types/pronunciation.rs index 1a013962c..df2d7ce74 100644 --- a/node/src/types/pronunciation.rs +++ b/node/src/types/pronunciation.rs @@ -1,26 +1,26 @@ -use internal::ToEnumWrapper; use napi_derive::napi; -use super::enums::EnumWrapper; +use crate::types::LanguageIdentifier; + use super::media_url::MediaURL; #[napi(object)] pub struct Pronunciation { - pub kind: Option, - pub value: String, - pub media: Vec, + pub kind: LanguageIdentifier, + pub value: String, + pub media: Vec, } impl From for Pronunciation { - fn from(pronunciation: odict::schema::Pronunciation) -> Self { - Self { - kind: pronunciation.kind.map(|k| k.to_enum_wrapper().into()), - value: pronunciation.value, - media: pronunciation - .media - .into_iter() - .map(MediaURL::from) - .collect(), + fn from(pronunciation: odict::schema::Pronunciation) -> Self { + Self { + kind: pronunciation.kind.into(), + value: pronunciation.value, + media: pronunciation + .media + .into_iter() + .map(MediaURL::from) + .collect(), + } } - } }