shared/api/endpoints/
audio.rs

1/// routes for the user audio library
2pub mod user {
3    use crate::{
4        api::{endpoints::ApiEndpoint, Method},
5        domain::{
6            audio::{
7                user::{
8                    UserAudioCreatePath, UserAudioDeletePath, UserAudioGetPath, UserAudioListPath,
9                    UserAudioListResponse, UserAudioResponse, UserAudioUploadPath,
10                    UserAudioUploadRequest, UserAudioUploadResponse,
11                },
12                AudioId,
13            },
14            CreateResponse,
15        },
16        error::EmptyError,
17    };
18
19    /// List audio files.
20    pub struct List;
21    impl ApiEndpoint for List {
22        type Path = UserAudioListPath;
23        type Req = ();
24        type Res = UserAudioListResponse;
25        type Err = EmptyError;
26        const METHOD: Method = Method::Get;
27    }
28
29    /// Get an audio file by ID.
30    pub struct Get;
31    impl ApiEndpoint for Get {
32        type Path = UserAudioGetPath;
33        type Req = ();
34        type Res = UserAudioResponse;
35        type Err = EmptyError;
36        const METHOD: Method = Method::Get;
37    }
38    /// Create an audio file.
39    pub struct Create;
40    impl ApiEndpoint for Create {
41        type Path = UserAudioCreatePath;
42        type Req = ();
43        type Res = CreateResponse<AudioId>;
44        type Err = EmptyError;
45        const METHOD: Method = Method::Post;
46    }
47
48    /// Upload an audio file. Returns a pre-signed URL for upload to Google Cloud Storage.
49    ///
50    /// Notes:
51    /// * can be used to update the raw data associated with the audio file.
52    pub struct Upload;
53    impl ApiEndpoint for Upload {
54        // raw bytes
55        type Path = UserAudioUploadPath;
56        type Req = UserAudioUploadRequest;
57        type Res = UserAudioUploadResponse;
58        type Err = EmptyError;
59        const METHOD: Method = Method::Put;
60    }
61
62    /// Delete an audio file.
63    pub struct Delete;
64    impl ApiEndpoint for Delete {
65        type Path = UserAudioDeletePath;
66        type Req = ();
67        type Res = ();
68        type Err = EmptyError;
69        const METHOD: Method = Method::Delete;
70    }
71}