Skip to main content

onebot_api/message/
signal_segment_builder.rs

1use super::segment_builder::SegmentBuilder;
2use super::send_segment::*;
3use super::utils::*;
4
5pub struct ImageDataBuilder {
6	raw: SegmentBuilder,
7	data: ImageData,
8}
9
10impl ImageDataBuilder {
11	pub fn new(raw: SegmentBuilder, file: impl ToString) -> Self {
12		Self {
13			raw,
14			data: ImageData {
15				file: file.to_string(),
16				image_type: None,
17				cache: None,
18				proxy: None,
19				timeout: None,
20			},
21		}
22	}
23
24	pub fn build(self) -> SegmentBuilder {
25		self.raw.and_push(self.data)
26	}
27
28	pub fn image_type(mut self, image_type: ImageType) -> Self {
29		self.data.image_type = Some(image_type);
30		self
31	}
32
33	pub fn cache(mut self, cache: bool) -> Self {
34		self.data.cache = Some(cache);
35		self
36	}
37
38	pub fn proxy(mut self, proxy: bool) -> Self {
39		self.data.proxy = Some(proxy);
40		self
41	}
42
43	pub fn timeout(mut self, timeout: i32) -> Self {
44		self.data.timeout = Some(timeout);
45		self
46	}
47}