grammers_client/types/
attributes.rs1use grammers_tl_types as tl;
9use std::{convert::TryInto, time::Duration};
10
11#[derive(Clone)]
12pub enum Attribute {
13 Audio {
14 duration: Duration,
15 title: Option<String>,
16 performer: Option<String>,
17 },
18 Voice {
19 duration: Duration,
20 waveform: Option<Vec<u8>>,
21 },
22 Video {
23 round_message: bool,
24 supports_streaming: bool,
25 duration: Duration,
26 w: i32,
27 h: i32,
28 },
29 FileName(String),
30}
31
32impl From<Attribute> for tl::enums::DocumentAttribute {
33 fn from(attr: Attribute) -> Self {
34 use Attribute::*;
35 match attr {
36 Audio {
37 duration,
38 title,
39 performer,
40 } => Self::Audio(tl::types::DocumentAttributeAudio {
41 voice: false,
42 duration: duration.as_secs().try_into().unwrap(),
43 title,
44 performer,
45 waveform: None,
46 }),
47 Voice { duration, waveform } => Self::Audio(tl::types::DocumentAttributeAudio {
48 voice: true,
49 duration: duration.as_secs().try_into().unwrap(),
50 title: None,
51 performer: None,
52 waveform,
53 }),
54 Video {
55 round_message,
56 supports_streaming,
57 duration,
58 w,
59 h,
60 } => Self::Video(tl::types::DocumentAttributeVideo {
61 round_message,
62 supports_streaming,
63 nosound: false,
64 duration: duration.as_secs_f64(),
65 w,
66 h,
67 preload_prefix_size: None,
68 video_start_ts: None,
69 video_codec: None,
70 }),
71 FileName(file_name) => {
72 Self::Filename(tl::types::DocumentAttributeFilename { file_name })
73 }
74 }
75 }
76}