Skip to main content

rsynko_x/
attachment.rs

1use crate::XSorts;
2use alux_sdk::case_mapping;
3
4/// Provides the carrier and constructor for one file a tweet carries.
5pub trait XAttachmentAlg: XSorts {
6    /// Defines one attachment from what the answer stated about it.
7    fn attachment(
8        &self,
9        identity: impl Into<String>,
10        kind: AttachmentKind,
11        address: impl Into<String>,
12    ) -> Self::Attachment;
13}
14
15/// Specifies what one attachment states about itself.
16pub trait XAttachmentViewAlg: XSorts {
17    /// Observes what the attachment is called among the others the tweet carries.
18    fn attachment_identity<'a>(&self, attachment: &'a Self::Attachment) -> &'a str;
19    /// Observes what kind of file it is.
20    fn attachment_kind(&self, attachment: &Self::Attachment) -> AttachmentKind;
21    /// Observes where its bytes are fetched from.
22    fn attachment_address<'a>(&self, attachment: &'a Self::Attachment) -> &'a str;
23}
24
25/// Denotes what kind of file a tweet carries.
26#[derive(Clone, Copy, Debug, PartialEq, Eq)]
27pub enum AttachmentKind {
28    /// Denotes a still picture.
29    Photo,
30    /// Denotes a video, which the answer states at several sizes.
31    Video,
32    /// Denotes a silent looping video, which was posted as an animation.
33    Animation,
34}
35
36case_mapping! {
37    AttachmentKind, &'static str as &str,
38        Photo     <=> "photo",
39        Video     <=> "video",
40        Animation <=> "animated_gif",
41}