Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rust APIのビルダー構造体を#[must_use]にする #910

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading