crabka_protocol/opt/rustwide/workdir/generated/
RemoveAccessControlEntryRecord.owned.rs1use crate::tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len};
4use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
5use bytes::{Buf, BufMut};
6pub const MIN_VERSION: i16 = 0;
7pub const MAX_VERSION: i16 = 0;
8pub const FLEXIBLE_MIN: i16 = 0;
9
10#[inline]
11fn is_flexible(version: i16) -> bool {
12 version >= FLEXIBLE_MIN
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, Default)]
16pub struct RemoveAccessControlEntryRecord {
17 pub id: crate::primitives::uuid::Uuid,
18 pub unknown_tagged_fields: UnknownTaggedFields,
19}
20impl Encode for RemoveAccessControlEntryRecord {
21 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
22 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
23 return Err(ProtocolError::SchemaMismatch(
24 "RemoveAccessControlEntryRecord version out of range",
25 ));
26 }
27 let flex = is_flexible(version);
28 if version >= 0 {
29 crate::primitives::uuid::put_uuid(buf, self.id);
30 }
31 if flex {
32 let tagged = WriteTaggedFields::new();
33 tagged.write(buf, &self.unknown_tagged_fields);
34 }
35 Ok(())
36 }
37 fn encoded_len(&self, version: i16) -> usize {
38 let flex = is_flexible(version);
39 let mut n: usize = 0;
40 if version >= 0 {
41 n += 16;
42 }
43 if flex {
44 let known_pairs: Vec<(u32, usize)> = Vec::new();
45 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
46 }
47 n
48 }
49}
50impl Decode<'_> for RemoveAccessControlEntryRecord {
51 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
52 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
53 return Err(ProtocolError::SchemaMismatch(
54 "RemoveAccessControlEntryRecord version out of range",
55 ));
56 }
57 let flex = is_flexible(version);
58 let mut out = Self::default();
59 if version >= 0 {
60 out.id = crate::primitives::uuid::get_uuid(buf)?;
61 }
62 if flex {
63 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
64 }
65 Ok(out)
66 }
67}
68#[cfg(test)]
69impl RemoveAccessControlEntryRecord {
70 #[must_use]
71 pub fn populated(version: i16) -> Self {
72 let mut m = Self::default();
73 if version >= 0 {
74 m.id = crate::primitives::uuid::Uuid([1u8; 16]);
75 }
76 m
77 }
78}
79
80#[must_use]
83#[allow(unused_comparisons)]
84pub fn default_json(version: i16) -> ::serde_json::Value {
85 let mut obj = ::serde_json::Map::new();
86 obj.insert(
87 "id".to_string(),
88 ::serde_json::Value::String("AAAAAAAAAAAAAAAAAAAAAA".to_string()),
89 );
90 ::serde_json::Value::Object(obj)
91}