shared/domain/
media.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Types for Media.

use crate::api::endpoints::PathPart;
use chrono::{DateTime, Utc};
use macros::make_path_parts;
use serde::{Deserialize, Serialize};
use url::Url;
use uuid::Uuid;

use crate::media::MediaKind;

make_path_parts!(MediaCreatePath => "/v1/media/image/url");

/// Response for adding a URL to the Web Media Library
#[derive(Serialize, Deserialize, Debug)]
pub struct UrlCreatedResponse {
    /// The ID of the media.
    pub id: Uuid,

    /// What kind of media this was inferred to be.
    pub kind: MediaKind,
}

/// Request for adding a URL to the Web Media Library
#[derive(Serialize, Deserialize, Debug)]
pub struct WebMediaUrlCreateRequest {
    /// The url.
    pub url: Url,
}

make_path_parts!(MediaUrlGetPath => "/v1/media/url/{}" => Url);

make_path_parts!(MediaIdGetPath => "/v1/media/id/{}" => Uuid);

/// Response for getting metadata for media from the web media library.
#[derive(Serialize, Deserialize, Debug)]
pub struct WebMediaMetadataResponse {
    /// The ID of the media
    pub id: Uuid,

    /// What kind of media this is
    pub kind: MediaKind,

    /// The urls associated with this media (can be empty)
    pub urls: Vec<Url>,

    /// When this media was added
    pub created_at: DateTime<Utc>,

    /// When this media was last updated, if ever.
    pub updated_at: Option<DateTime<Utc>>,
}

make_path_parts!(MediaUrlDeletePath => "/v1/media/url/{}" => Url);

make_path_parts!(MediaIdDeletePath => "/v1/media/id/{}" => Uuid);