Skip to content

Commit

Permalink
feat: Rust APIのビルダー構造体を#[must_use]にする (#910)
Browse files Browse the repository at this point in the history
Refs: #388, #908
  • Loading branch information
qryxip authored Dec 27, 2024
1 parent f755609 commit 0248b7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/voicevox_core/src/infer/runtimes/onnxruntime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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")]
Expand Down
9 changes: 9 additions & 0 deletions crates/voicevox_core/src/synthesizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,7 @@ pub(crate) mod blocking {
}
}

#[must_use]
pub struct Builder<O> {
onnxruntime: &'static crate::blocking::Onnxruntime,
open_jtalk: O,
Expand Down Expand Up @@ -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<O, SingleTasked>,
audio_query: &'a AudioQuery,
Expand All @@ -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<O, SingleTasked>,
audio_query: &'a AudioQuery,
Expand All @@ -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<O, SingleTasked>,
kana: &'a str,
Expand All @@ -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<O, SingleTasked>,
text: &'a str,
Expand Down Expand Up @@ -2174,6 +2179,7 @@ pub(crate) mod nonblocking {
}
}

#[must_use]
pub struct Builder<O> {
onnxruntime: &'static crate::nonblocking::Onnxruntime,
open_jtalk: O,
Expand Down Expand Up @@ -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<O, BlockingThreadPool>,
audio_query: &'a AudioQuery,
Expand All @@ -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<O, BlockingThreadPool>,
kana: &'a str,
Expand All @@ -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<O, BlockingThreadPool>,
text: &'a str,
Expand Down

0 comments on commit 0248b7a

Please sign in to comment.