qdrant_client/builders/
abort_shard_transfer_builder.rs1use crate::qdrant::*;
2
3pub struct AbortShardTransferBuilder {
4 pub(crate) shard_id: Option<u32>,
6 pub(crate) to_shard_id: Option<Option<u32>>,
7 pub(crate) from_peer_id: Option<u64>,
8 pub(crate) to_peer_id: Option<u64>,
9}
10
11impl AbortShardTransferBuilder {
12 #[allow(unused_mut)]
14 pub fn shard_id(self, value: u32) -> Self {
15 let mut new = self;
16 new.shard_id = Option::Some(value);
17 new
18 }
19 #[allow(unused_mut)]
20 pub fn to_shard_id(self, value: u32) -> Self {
21 let mut new = self;
22 new.to_shard_id = Option::Some(Option::Some(value));
23 new
24 }
25 #[allow(unused_mut)]
26 pub fn from_peer_id(self, value: u64) -> Self {
27 let mut new = self;
28 new.from_peer_id = Option::Some(value);
29 new
30 }
31 #[allow(unused_mut)]
32 pub fn to_peer_id(self, value: u64) -> Self {
33 let mut new = self;
34 new.to_peer_id = Option::Some(value);
35 new
36 }
37 fn build_inner(self) -> Result<AbortShardTransfer, AbortShardTransferBuilderError> {
38 Ok(AbortShardTransfer {
39 shard_id: match self.shard_id {
40 Some(value) => value,
41 None => {
42 return Result::Err(core::convert::Into::into(
43 ::derive_builder::UninitializedFieldError::from("shard_id"),
44 ));
45 }
46 },
47 to_shard_id: self.to_shard_id.unwrap_or_default(),
48 from_peer_id: match self.from_peer_id {
49 Some(value) => value,
50 None => {
51 return Result::Err(core::convert::Into::into(
52 ::derive_builder::UninitializedFieldError::from("from_peer_id"),
53 ));
54 }
55 },
56 to_peer_id: match self.to_peer_id {
57 Some(value) => value,
58 None => {
59 return Result::Err(core::convert::Into::into(
60 ::derive_builder::UninitializedFieldError::from("to_peer_id"),
61 ));
62 }
63 },
64 })
65 }
66 fn create_empty() -> Self {
68 Self {
69 shard_id: core::default::Default::default(),
70 to_shard_id: core::default::Default::default(),
71 from_peer_id: core::default::Default::default(),
72 to_peer_id: core::default::Default::default(),
73 }
74 }
75}
76
77impl From<AbortShardTransferBuilder> for AbortShardTransfer {
78 fn from(value: AbortShardTransferBuilder) -> Self {
79 value.build_inner().unwrap_or_else(|_| {
80 panic!(
81 "Failed to convert {0} to {1}",
82 "AbortShardTransferBuilder", "AbortShardTransfer"
83 )
84 })
85 }
86}
87
88impl AbortShardTransferBuilder {
89 pub fn build(self) -> AbortShardTransfer {
91 self.build_inner().unwrap_or_else(|_| {
92 panic!(
93 "Failed to build {0} into {1}",
94 "AbortShardTransferBuilder", "AbortShardTransfer"
95 )
96 })
97 }
98}
99
100impl AbortShardTransferBuilder {
101 pub(crate) fn empty() -> Self {
102 Self::create_empty()
103 }
104}
105
106#[non_exhaustive]
109#[derive(Debug)]
110pub enum AbortShardTransferBuilderError {
111 UninitializedField(&'static str),
113 ValidationError(String),
115}
116
117impl std::fmt::Display for AbortShardTransferBuilderError {
119 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
120 match self {
121 Self::UninitializedField(field) => {
122 write!(f, "`{}` must be initialized", field)
123 }
124 Self::ValidationError(error) => write!(f, "{}", error),
125 }
126 }
127}
128
129impl std::error::Error for AbortShardTransferBuilderError {}
130
131impl From<derive_builder::UninitializedFieldError> for AbortShardTransferBuilderError {
132 fn from(error: derive_builder::UninitializedFieldError) -> Self {
133 Self::UninitializedField(error.field_name())
134 }
135}
136
137impl From<String> for AbortShardTransferBuilderError {
138 fn from(error: String) -> Self {
139 Self::ValidationError(error)
140 }
141}