rig/client/
audio_generation.rs1#[cfg(feature = "audio")]
2mod audio {
3 #[allow(deprecated)]
4 use crate::audio_generation::AudioGenerationModelDyn;
5 use crate::audio_generation::{
6 AudioGenerationError, AudioGenerationModel, AudioGenerationRequest, AudioGenerationResponse,
7 };
8 use crate::client::Nothing;
9 use std::future::Future;
10 use std::sync::Arc;
11
12 pub trait AudioGenerationClient {
15 type AudioGenerationModel: AudioGenerationModel<Client = Self>;
17
18 fn audio_generation_model(&self, model: impl Into<String>) -> Self::AudioGenerationModel {
30 Self::AudioGenerationModel::make(self, model)
31 }
32 }
33
34 #[allow(deprecated)]
35 #[deprecated(
36 since = "0.25.0",
37 note = "`DynClientBuilder` and related features have been deprecated and will be removed in a future release. In this case, use `ImageGenerationModel` instead."
38 )]
39 pub trait AudioGenerationClientDyn {
40 fn audio_generation_model<'a>(&self, model: &str) -> Box<dyn AudioGenerationModelDyn + 'a>;
41 }
42
43 #[allow(deprecated)]
44 impl<T, M> AudioGenerationClientDyn for T
45 where
46 T: AudioGenerationClient<AudioGenerationModel = M>,
47 M: AudioGenerationModel + 'static,
48 {
49 fn audio_generation_model<'a>(&self, model: &str) -> Box<dyn AudioGenerationModelDyn + 'a> {
50 Box::new(self.audio_generation_model(model))
51 }
52 }
53
54 #[deprecated(
55 since = "0.25.0",
56 note = "`DynClientBuilder` and related features have been deprecated and will be removed in a future release. In this case, use `ImageGenerationModel` instead."
57 )]
58 #[derive(Clone)]
60 pub struct AudioGenerationModelHandle<'a> {
61 #[allow(deprecated)]
62 pub(crate) inner: Arc<dyn AudioGenerationModelDyn + 'a>,
63 }
64
65 #[allow(deprecated)]
66 impl AudioGenerationModel for AudioGenerationModelHandle<'_> {
67 type Response = ();
68 type Client = Nothing;
69
70 fn make(_: &Self::Client, _: impl Into<String>) -> Self {
73 panic!(
74 "Function should be unreachable as Self can only be constructed from another 'AudioGenerationModel'"
75 )
76 }
77
78 fn audio_generation(
79 &self,
80 request: AudioGenerationRequest,
81 ) -> impl Future<
82 Output = Result<AudioGenerationResponse<Self::Response>, AudioGenerationError>,
83 > + Send {
84 self.inner.audio_generation(request)
85 }
86 }
87}
88
89#[cfg(feature = "audio")]
90pub use audio::*;