From d6489ccb417f2a579ab2cc5aabb3acdf2f65a0fd Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sun, 3 Sep 2023 16:38:37 +0900 Subject: [PATCH] =?UTF-8?q?#558=20=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/voicevox_core/src/__internal.rs | 6 ++---- crates/voicevox_core/src/error.rs | 7 +++++++ crates/voicevox_core_java_api/src/user_dict.rs | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/voicevox_core/src/__internal.rs b/crates/voicevox_core/src/__internal.rs index c37f50601..673ccfa73 100644 --- a/crates/voicevox_core/src/__internal.rs +++ b/crates/voicevox_core/src/__internal.rs @@ -1,11 +1,9 @@ // FIXME: 要議論: https://github.com/VOICEVOX/voicevox_core/issues/595 -use std::fmt::Display; - pub fn to_zenkaku(surface: &str) -> String { crate::user_dict::to_zenkaku(surface) } -pub fn validate_pronunciation(pronunciation: &str) -> std::result::Result<(), impl Display> { - crate::user_dict::validate_pronunciation(pronunciation) +pub fn validate_pronunciation(pronunciation: &str) -> crate::Result<()> { + crate::user_dict::validate_pronunciation(pronunciation).map_err(Into::into) } diff --git a/crates/voicevox_core/src/error.rs b/crates/voicevox_core/src/error.rs index f7c5aeff2..1d9eda849 100644 --- a/crates/voicevox_core/src/error.rs +++ b/crates/voicevox_core/src/error.rs @@ -23,6 +23,13 @@ impl From for Error { } } +// FIXME: `ErrorRepr::InvalidWord`を`#[error(transparent)]`にする +impl From for Error { + fn from(err: InvalidWordError) -> Self { + ErrorRepr::InvalidWord(err).into() + } +} + impl Error { /// 対応する[`ErrorKind`]を返す。 pub fn kind(&self) -> ErrorKind { diff --git a/crates/voicevox_core_java_api/src/user_dict.rs b/crates/voicevox_core_java_api/src/user_dict.rs index a89c11d8e..4f7bc78d8 100644 --- a/crates/voicevox_core_java_api/src/user_dict.rs +++ b/crates/voicevox_core_java_api/src/user_dict.rs @@ -213,7 +213,7 @@ extern "system" fn Java_jp_hiroshiba_voicevoxcore_UserDict_rsToZenkaku<'local>( let text = env.get_string(&text)?; let text = text.to_str()?; - let text = voicevox_core::to_zenkaku(text); + let text = voicevox_core::__internal::to_zenkaku(text); let text = env.new_string(text)?; Ok(text.into_raw()) @@ -230,7 +230,7 @@ extern "system" fn Java_jp_hiroshiba_voicevoxcore_UserDict_rsValidatePronunciati let text = env.get_string(&text)?; let text = text.to_str()?; - voicevox_core::validate_pronunciation(text)?; + voicevox_core::__internal::validate_pronunciation(text)?; Ok(()) })