qdrant_client/builders/
image_builder.rs

1use std::collections::HashMap;
2
3use crate::qdrant::{value, Image, Value};
4
5impl Image {
6    pub fn new_from_url(url: impl Into<String>, model: impl Into<String>) -> Self {
7        Self {
8            image: Some(Value {
9                kind: Some(value::Kind::StringValue(url.into())),
10            }),
11            model: model.into(),
12            options: HashMap::new(),
13        }
14    }
15
16    pub fn new_from_base64(base64: impl Into<String>, model: impl Into<String>) -> Self {
17        Self {
18            image: Some(Value {
19                kind: Some(value::Kind::StringValue(base64.into())),
20            }),
21            model: model.into(),
22            options: HashMap::new(),
23        }
24    }
25}
26
27pub struct ImageBuilder {
28    image: Option<Value>,
29    model: String,
30    options: HashMap<String, Value>,
31}
32
33impl ImageBuilder {
34    pub fn new_from_url(url: impl Into<String>, model: impl Into<String>) -> Self {
35        Self {
36            image: Some(Value {
37                kind: Some(value::Kind::StringValue(url.into())),
38            }),
39            model: model.into(),
40            options: HashMap::new(),
41        }
42    }
43
44    pub fn new_from_base64(base64: impl Into<String>, model: impl Into<String>) -> Self {
45        Self {
46            image: Some(Value {
47                kind: Some(value::Kind::StringValue(base64.into())),
48            }),
49            model: model.into(),
50            options: HashMap::new(),
51        }
52    }
53
54    pub fn image(mut self, image: Value) -> Self {
55        self.image = Some(image);
56        self
57    }
58
59    pub fn model(mut self, model: impl Into<String>) -> Self {
60        self.model = model.into();
61        self
62    }
63
64    pub fn options(mut self, options: HashMap<String, Value>) -> Self {
65        self.options = options;
66        self
67    }
68
69    pub fn build(self) -> Image {
70        Image {
71            image: self.image,
72            model: self.model,
73            options: self.options,
74        }
75    }
76}