kanidmd_lib/valueset/
message.rs1use crate::prelude::*;
2use crate::schema::SchemaAttribute;
3use crate::valueset::ScimResolveStatus;
4use crate::valueset::{DbValueSetV2, ValueSet};
5use kanidm_proto::v1::OutboundMessage;
6
7#[derive(Debug, Clone)]
8pub struct ValueSetMessage {
9 message: OutboundMessage,
10}
11
12impl ValueSetMessage {
13 pub fn new(message: OutboundMessage) -> Box<Self> {
14 Box::new(ValueSetMessage { message })
15 }
16}
17
18impl ValueSetT for ValueSetMessage {
19 fn insert_checked(&mut self, _value: Value) -> Result<bool, OperationError> {
20 debug_assert!(false);
21 Err(OperationError::InvalidValueState)
22 }
23
24 fn clear(&mut self) {
25 debug_assert!(false);
26 }
27
28 fn remove(&mut self, _pv: &PartialValue, _cid: &Cid) -> bool {
29 debug_assert!(false);
30 false
31 }
32
33 fn contains(&self, _pv: &PartialValue) -> bool {
34 false
35 }
36
37 fn substring(&self, _pv: &PartialValue) -> bool {
38 false
39 }
40
41 fn startswith(&self, _pv: &PartialValue) -> bool {
42 false
43 }
44
45 fn endswith(&self, _pv: &PartialValue) -> bool {
46 false
47 }
48
49 fn lessthan(&self, _pv: &PartialValue) -> bool {
50 false
51 }
52
53 fn len(&self) -> usize {
54 1
55 }
56
57 fn syntax(&self) -> SyntaxType {
58 SyntaxType::Message
59 }
60
61 fn validate(&self, _schema_attr: &SchemaAttribute) -> bool {
62 true
63 }
64
65 fn to_proto_string_clone_iter(&self) -> Box<dyn Iterator<Item = String> + '_> {
66 Box::new(std::iter::empty())
67 }
68
69 fn to_scim_value(&self) -> Option<ScimResolveStatus> {
70 Some(ScimResolveStatus::Resolved(ScimValueKanidm::from(
71 self.message.clone(),
72 )))
73 }
74
75 fn to_db_valueset_v2(&self) -> DbValueSetV2 {
76 DbValueSetV2::Message(self.message.clone())
77 }
78
79 fn to_partialvalue_iter(&self) -> Box<dyn Iterator<Item = PartialValue> + '_> {
80 Box::new(std::iter::empty())
81 }
82
83 fn to_value_iter(&self) -> Box<dyn Iterator<Item = Value> + '_> {
84 Box::new(std::iter::empty())
85 }
86
87 fn equal(&self, other: &ValueSet) -> bool {
88 if let Some(other) = other.as_message() {
89 &self.message == other
90 } else {
91 debug_assert!(false);
92 false
93 }
94 }
95
96 fn merge(&mut self, _other: &ValueSet) -> Result<(), OperationError> {
97 debug_assert!(false);
98 Err(OperationError::InvalidValueState)
99 }
100
101 fn as_message(&self) -> Option<&OutboundMessage> {
102 Some(&self.message)
103 }
104}