Skip to main content

crabka_protocol/opt/rustwide/workdir/generated/
RemoveAccessControlEntryRecord.owned.rs

1// AUTO-GENERATED by crabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2
3use 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#[inline]
10fn is_flexible(version: i16) -> bool {
11    version >= FLEXIBLE_MIN
12}
13#[derive(Debug, Clone, PartialEq, Eq, Default)]
14pub struct RemoveAccessControlEntryRecord {
15    pub id: crate::primitives::uuid::Uuid,
16    pub unknown_tagged_fields: UnknownTaggedFields,
17}
18impl Encode for RemoveAccessControlEntryRecord {
19    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
20        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
21            return Err(ProtocolError::SchemaMismatch(
22                "RemoveAccessControlEntryRecord version out of range",
23            ));
24        }
25        let flex = is_flexible(version);
26        if version >= 0 {
27            crate::primitives::uuid::put_uuid(buf, self.id);
28        }
29        if flex {
30            let tagged = WriteTaggedFields::new();
31            tagged.write(buf, &self.unknown_tagged_fields);
32        }
33        Ok(())
34    }
35    fn encoded_len(&self, version: i16) -> usize {
36        let flex = is_flexible(version);
37        let mut n: usize = 0;
38        if version >= 0 {
39            n += 16;
40        }
41        if flex {
42            let known_pairs: Vec<(u32, usize)> = Vec::new();
43            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
44        }
45        n
46    }
47}
48impl Decode<'_> for RemoveAccessControlEntryRecord {
49    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
50        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
51            return Err(ProtocolError::SchemaMismatch(
52                "RemoveAccessControlEntryRecord version out of range",
53            ));
54        }
55        let flex = is_flexible(version);
56        let mut out = Self::default();
57        if version >= 0 {
58            out.id = crate::primitives::uuid::get_uuid(buf)?;
59        }
60        if flex {
61            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
62        }
63        Ok(out)
64    }
65}
66#[cfg(test)]
67impl RemoveAccessControlEntryRecord {
68    #[must_use]
69    pub fn populated(version: i16) -> Self {
70        let mut m = Self::default();
71        if version >= 0 {
72            m.id = crate::primitives::uuid::Uuid([1u8; 16]);
73        }
74        m
75    }
76}
77/// Default JSON payload matching `Self::default()` for JVM oracle differential testing.
78/// Only includes fields valid for the given version.
79#[must_use]
80#[allow(unused_comparisons)]
81pub fn default_json(version: i16) -> ::serde_json::Value {
82    let mut obj = ::serde_json::Map::new();
83    obj.insert(
84        "id".to_string(),
85        ::serde_json::Value::String("AAAAAAAAAAAAAAAAAAAAAA".to_string()),
86    );
87    ::serde_json::Value::Object(obj)
88}