From 0248b7aa3b53917e707eeb5e6a86154dda464504 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 28 Dec 2024 00:11:51 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Rust=20API=E3=81=AE=E3=83=93=E3=83=AB?= =?UTF-8?q?=E3=83=80=E3=83=BC=E6=A7=8B=E9=80=A0=E4=BD=93=E3=82=92`#[must?= =?UTF-8?q?=5Fuse]`=E3=81=AB=E3=81=99=E3=82=8B=20(#910)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: #388, #908 --- crates/voicevox_core/src/infer/runtimes/onnxruntime.rs | 2 ++ crates/voicevox_core/src/synthesizer.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs b/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs index 3cfd11608..bdb4a7daa 100644 --- a/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs +++ b/crates/voicevox_core/src/infer/runtimes/onnxruntime.rs @@ -425,6 +425,7 @@ pub(crate) mod blocking { /// [`Onnxruntime::load_once`]のビルダー。 #[cfg(feature = "load-onnxruntime")] + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct LoadOnce { filename: std::ffi::OsString, } @@ -586,6 +587,7 @@ pub(crate) mod nonblocking { /// [`Onnxruntime::load_once`]のビルダー。 #[cfg(feature = "load-onnxruntime")] #[derive(Default)] + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct LoadOnce(super::blocking::LoadOnce); #[cfg(feature = "load-onnxruntime")] diff --git a/crates/voicevox_core/src/synthesizer.rs b/crates/voicevox_core/src/synthesizer.rs index 89a959ae2..7c559ca39 100644 --- a/crates/voicevox_core/src/synthesizer.rs +++ b/crates/voicevox_core/src/synthesizer.rs @@ -1746,6 +1746,7 @@ pub(crate) mod blocking { } } + #[must_use] pub struct Builder { onnxruntime: &'static crate::blocking::Onnxruntime, open_jtalk: O, @@ -1779,6 +1780,7 @@ pub(crate) mod blocking { } // TODO: この`O`は削れるはず + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct PrecomputeRender<'a, O> { synthesizer: &'a Inner, audio_query: &'a AudioQuery, @@ -1801,6 +1803,7 @@ pub(crate) mod blocking { } // TODO: この`O`は削れるはず + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct Synthesis<'a, O> { synthesizer: &'a Inner, audio_query: &'a AudioQuery, @@ -1823,6 +1826,7 @@ pub(crate) mod blocking { } // TODO: この`O`は削れるはず + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct TtsFromKana<'a, O> { synthesizer: &'a Inner, kana: &'a str, @@ -1844,6 +1848,7 @@ pub(crate) mod blocking { } } + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct Tts<'a, O> { synthesizer: &'a Inner, text: &'a str, @@ -2174,6 +2179,7 @@ pub(crate) mod nonblocking { } } + #[must_use] pub struct Builder { onnxruntime: &'static crate::nonblocking::Onnxruntime, open_jtalk: O, @@ -2214,6 +2220,7 @@ pub(crate) mod nonblocking { } // TODO: この`O`は削れるはず + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct Synthesis<'a, O> { synthesizer: &'a Inner, audio_query: &'a AudioQuery, @@ -2236,6 +2243,7 @@ pub(crate) mod nonblocking { } // TODO: この`O`は削れるはず + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct TtsFromKana<'a, O> { synthesizer: &'a Inner, kana: &'a str, @@ -2257,6 +2265,7 @@ pub(crate) mod nonblocking { } } + #[must_use = "this is a builder. it does nothing until `exec`uted"] pub struct Tts<'a, O> { synthesizer: &'a Inner, text: &'a str,