1use crate::primitives::fixed::{
3 get_i16, get_i32, get_i64, get_u16, put_i16, put_i32, put_i64, put_u16,
4};
5use crate::primitives::string_bytes::{
6 compact_string_len, put_compact_string, put_string, string_len,
7};
8use crate::primitives::string_bytes::{put_bytes, put_compact_bytes};
9use crate::primitives::string_bytes_borrowed::{get_bytes_borrowed, get_compact_bytes_borrowed};
10use crate::primitives::string_bytes_borrowed::{get_compact_string_borrowed, get_string_borrowed};
11use crate::tagged_fields::{
12 WriteTaggedFields, encode_to_bytes, read_tagged_fields, tagged_fields_len,
13};
14use crate::{Decode, DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields};
15use bytes::BufMut;
16pub const API_KEY: i16 = 59;
17pub const MIN_VERSION: i16 = 0;
18pub const MAX_VERSION: i16 = 1;
19pub const FLEXIBLE_MIN: i16 = 0;
20#[inline]
21fn is_flexible(version: i16) -> bool {
22 version >= FLEXIBLE_MIN
23}
24#[derive(Debug, Clone, PartialEq, Eq, Default)]
25pub struct FetchSnapshotResponse<'a> {
26 pub throttle_time_ms: i32,
27 pub error_code: i16,
28 pub topics: Vec<TopicSnapshot<'a>>,
29 pub node_endpoints: Vec<crate::owned::fetch_snapshot_response::NodeEndpoint>,
30 pub unknown_tagged_fields: UnknownTaggedFields,
31}
32impl FetchSnapshotResponse<'_> {
33 pub fn to_owned(&self) -> crate::owned::fetch_snapshot_response::FetchSnapshotResponse {
34 crate::owned::fetch_snapshot_response::FetchSnapshotResponse {
35 throttle_time_ms: (self.throttle_time_ms),
36 error_code: (self.error_code),
37 topics: (self.topics).iter().map(TopicSnapshot::to_owned).collect(),
38 node_endpoints: self.node_endpoints.clone(),
39 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
40 }
41 }
42}
43impl Encode for FetchSnapshotResponse<'_> {
44 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
45 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
46 return Err(ProtocolError::UnsupportedVersion {
47 api_key: API_KEY,
48 version,
49 });
50 }
51 let flex = is_flexible(version);
52 if version >= 0 {
53 put_i32(buf, self.throttle_time_ms);
54 }
55 if version >= 0 {
56 put_i16(buf, self.error_code);
57 }
58 if version >= 0 {
59 {
60 crate::primitives::array::put_array_len(buf, (self.topics).len(), flex);
61 for it in &self.topics {
62 it.encode(buf, version)?;
63 }
64 }
65 }
66 if flex {
67 let mut tagged = WriteTaggedFields::new();
68 if !(crate::codegen_helpers::is_default(&self.node_endpoints)) {
69 let payload = encode_to_bytes(
70 {
71 let prefix = crate::primitives::array::array_len_prefix_len(
72 (self.node_endpoints).len(),
73 flex,
74 );
75 let body: usize = (self.node_endpoints)
76 .iter()
77 .map(|it| it.encoded_len(version))
78 .sum();
79 prefix + body
80 },
81 |b| {
82 {
83 crate::primitives::array::put_array_len(
84 b,
85 (self.node_endpoints).len(),
86 flex,
87 );
88 for it in &self.node_endpoints {
89 it.encode(b, version)?;
90 }
91 };
92 Ok(())
93 },
94 );
95 tagged.add(0, payload);
96 }
97 tagged.write(buf, &self.unknown_tagged_fields);
98 }
99 Ok(())
100 }
101 fn encoded_len(&self, version: i16) -> usize {
102 let flex = is_flexible(version);
103 let mut n: usize = 0;
104 if version >= 0 {
105 n += 4;
106 }
107 if version >= 0 {
108 n += 2;
109 }
110 if version >= 0 {
111 n += {
112 let prefix =
113 crate::primitives::array::array_len_prefix_len((self.topics).len(), flex);
114 let body: usize = (self.topics).iter().map(|it| it.encoded_len(version)).sum();
115 prefix + body
116 };
117 }
118 if flex {
119 let mut known_pairs: Vec<(u32, usize)> = Vec::new();
120 if !(crate::codegen_helpers::is_default(&self.node_endpoints)) {
121 known_pairs.push((0, {
122 let prefix = crate::primitives::array::array_len_prefix_len(
123 (self.node_endpoints).len(),
124 flex,
125 );
126 let body: usize = (self.node_endpoints)
127 .iter()
128 .map(|it| it.encoded_len(version))
129 .sum();
130 prefix + body
131 }));
132 }
133 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
134 }
135 n
136 }
137}
138impl<'de> DecodeBorrow<'de> for FetchSnapshotResponse<'de> {
139 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
140 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
141 return Err(ProtocolError::UnsupportedVersion {
142 api_key: API_KEY,
143 version,
144 });
145 }
146 let flex = is_flexible(version);
147 let mut out = Self::default();
148 if version >= 0 {
149 out.throttle_time_ms = get_i32(buf)?;
150 }
151 if version >= 0 {
152 out.error_code = get_i16(buf)?;
153 }
154 if version >= 0 {
155 out.topics = {
156 let n = crate::primitives::array::get_array_len(buf, flex)?;
157 let mut v = Vec::with_capacity(n);
158 for _ in 0..n {
159 v.push(TopicSnapshot::decode_borrow(buf, version)?);
160 }
161 v
162 };
163 }
164 if flex {
165 let mut tag_node_endpoints = None;
166 out.unknown_tagged_fields = read_tagged_fields(buf, |tag, payload| match tag {
167 0 => {
168 tag_node_endpoints = Some({
169 let b: &mut &[u8] = payload;
170 {
171 let n = crate::primitives::array::get_array_len(b, flex)?;
172 let mut v = Vec::with_capacity(n);
173 for _ in 0..n {
174 v.push(
175 crate::owned::fetch_snapshot_response::NodeEndpoint::decode(
176 b, version,
177 )?,
178 );
179 }
180 v
181 }
182 });
183 Ok(true)
184 }
185 _ => Ok(false),
186 })?;
187 if let Some(v) = tag_node_endpoints {
188 out.node_endpoints = v;
189 }
190 }
191 Ok(out)
192 }
193}
194#[cfg(test)]
195impl FetchSnapshotResponse<'_> {
196 #[must_use]
197 pub fn populated(version: i16) -> Self {
198 let mut m = Self::default();
199 if version >= 0 {
200 m.throttle_time_ms = 1i32;
201 }
202 if version >= 0 {
203 m.error_code = 1i16;
204 }
205 if version >= 0 {
206 m.topics = vec![TopicSnapshot::populated(version)];
207 }
208 if version >= 1 {
209 m.node_endpoints =
210 vec![crate::owned::fetch_snapshot_response::NodeEndpoint::populated(version)];
211 }
212 m
213 }
214}
215#[derive(Debug, Clone, PartialEq, Eq, Default)]
216pub struct TopicSnapshot<'a> {
217 pub name: &'a str,
218 pub partitions: Vec<PartitionSnapshot<'a>>,
219 pub unknown_tagged_fields: UnknownTaggedFields,
220}
221impl TopicSnapshot<'_> {
222 pub fn to_owned(&self) -> crate::owned::fetch_snapshot_response::TopicSnapshot {
223 crate::owned::fetch_snapshot_response::TopicSnapshot {
224 name: (self.name).to_string(),
225 partitions: (self.partitions)
226 .iter()
227 .map(PartitionSnapshot::to_owned)
228 .collect(),
229 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
230 }
231 }
232}
233impl Encode for TopicSnapshot<'_> {
234 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
235 let flex = version >= 0;
236 if version >= 0 {
237 if flex {
238 put_compact_string(buf, self.name);
239 } else {
240 put_string(buf, self.name);
241 }
242 }
243 if version >= 0 {
244 {
245 crate::primitives::array::put_array_len(buf, (self.partitions).len(), flex);
246 for it in &self.partitions {
247 it.encode(buf, version)?;
248 }
249 }
250 }
251 if flex {
252 let tagged = WriteTaggedFields::new();
253 tagged.write(buf, &self.unknown_tagged_fields);
254 }
255 Ok(())
256 }
257 fn encoded_len(&self, version: i16) -> usize {
258 let flex = version >= 0;
259 let mut n: usize = 0;
260 if version >= 0 {
261 n += if flex {
262 compact_string_len(self.name)
263 } else {
264 string_len(self.name)
265 };
266 }
267 if version >= 0 {
268 n += {
269 let prefix =
270 crate::primitives::array::array_len_prefix_len((self.partitions).len(), flex);
271 let body: usize = (self.partitions)
272 .iter()
273 .map(|it| it.encoded_len(version))
274 .sum();
275 prefix + body
276 };
277 }
278 if flex {
279 let known_pairs: Vec<(u32, usize)> = Vec::new();
280 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
281 }
282 n
283 }
284}
285impl<'de> DecodeBorrow<'de> for TopicSnapshot<'de> {
286 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
287 let flex = version >= 0;
288 let mut out = Self::default();
289 if version >= 0 {
290 out.name = if flex {
291 get_compact_string_borrowed(buf)?
292 } else {
293 get_string_borrowed(buf)?
294 };
295 }
296 if version >= 0 {
297 out.partitions = {
298 let n = crate::primitives::array::get_array_len(buf, flex)?;
299 let mut v = Vec::with_capacity(n);
300 for _ in 0..n {
301 v.push(PartitionSnapshot::decode_borrow(buf, version)?);
302 }
303 v
304 };
305 }
306 if flex {
307 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
308 }
309 Ok(out)
310 }
311}
312#[cfg(test)]
313impl TopicSnapshot<'_> {
314 #[must_use]
315 pub fn populated(version: i16) -> Self {
316 let mut m = Self::default();
317 if version >= 0 {
318 m.name = "x";
319 }
320 if version >= 0 {
321 m.partitions = vec![PartitionSnapshot::populated(version)];
322 }
323 m
324 }
325}
326#[derive(Debug, Clone, PartialEq, Eq, Default)]
327pub struct PartitionSnapshot<'a> {
328 pub index: i32,
329 pub error_code: i16,
330 pub snapshot_id: SnapshotId,
331 pub size: i64,
332 pub position: i64,
333 pub unaligned_records: crate::records::RecordsPayloadBorrowed<'a>,
334 pub current_leader: LeaderIdAndEpoch,
335 pub unknown_tagged_fields: UnknownTaggedFields,
336}
337impl PartitionSnapshot<'_> {
338 pub fn to_owned(&self) -> crate::owned::fetch_snapshot_response::PartitionSnapshot {
339 crate::owned::fetch_snapshot_response::PartitionSnapshot {
340 index: (self.index),
341 error_code: (self.error_code),
342 snapshot_id: (self.snapshot_id).to_owned(),
343 size: (self.size),
344 position: (self.position),
345 unaligned_records: (self.unaligned_records)
346 .to_owned()
347 .expect("records to_owned"),
348 current_leader: (self.current_leader).to_owned(),
349 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
350 }
351 }
352}
353impl Encode for PartitionSnapshot<'_> {
354 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
355 let flex = version >= 0;
356 if version >= 0 {
357 put_i32(buf, self.index);
358 }
359 if version >= 0 {
360 put_i16(buf, self.error_code);
361 }
362 if version >= 0 {
363 self.snapshot_id.encode(buf, version)?;
364 }
365 if version >= 0 {
366 put_i64(buf, self.size);
367 }
368 if version >= 0 {
369 put_i64(buf, self.position);
370 }
371 if version >= 0 {
372 {
373 let mut __rb_buf = bytes::BytesMut::new();
374 <crate::records::RecordsPayloadBorrowed as crate::Encode>::encode(
375 &self.unaligned_records,
376 &mut __rb_buf,
377 version,
378 )?;
379 if flex {
380 put_compact_bytes(buf, &__rb_buf);
381 } else {
382 put_bytes(buf, &__rb_buf);
383 }
384 }
385 }
386 if flex {
387 let mut tagged = WriteTaggedFields::new();
388 if !(crate::codegen_helpers::is_default(&self.current_leader)) {
389 let payload = encode_to_bytes(self.current_leader.encoded_len(version), |b| {
390 self.current_leader.encode(b, version)?;
391 Ok(())
392 });
393 tagged.add(0, payload);
394 }
395 tagged.write(buf, &self.unknown_tagged_fields);
396 }
397 Ok(())
398 }
399 fn encoded_len(&self, version: i16) -> usize {
400 let flex = version >= 0;
401 let mut n: usize = 0;
402 if version >= 0 {
403 n += 4;
404 }
405 if version >= 0 {
406 n += 2;
407 }
408 if version >= 0 {
409 n += self.snapshot_id.encoded_len(version);
410 }
411 if version >= 0 {
412 n += 8;
413 }
414 if version >= 0 {
415 n += 8;
416 }
417 if version >= 0 {
418 n += {
419 let __rb_len =
420 <crate::records::RecordsPayloadBorrowed as crate::Encode>::encoded_len(
421 &(self.unaligned_records),
422 version,
423 );
424 if flex {
425 crate::primitives::string_bytes::compact_bytes_len_from_size(__rb_len)
426 } else {
427 4 + __rb_len
428 }
429 };
430 }
431 if flex {
432 let mut known_pairs: Vec<(u32, usize)> = Vec::new();
433 if !(crate::codegen_helpers::is_default(&self.current_leader)) {
434 known_pairs.push((0, self.current_leader.encoded_len(version)));
435 }
436 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
437 }
438 n
439 }
440}
441impl<'de> DecodeBorrow<'de> for PartitionSnapshot<'de> {
442 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
443 let flex = version >= 0;
444 let mut out = Self::default();
445 if version >= 0 {
446 out.index = get_i32(buf)?;
447 }
448 if version >= 0 {
449 out.error_code = get_i16(buf)?;
450 }
451 if version >= 0 {
452 out.snapshot_id = SnapshotId::decode_borrow(buf, version)?;
453 }
454 if version >= 0 {
455 out.size = get_i64(buf)?;
456 }
457 if version >= 0 {
458 out.position = get_i64(buf)?;
459 }
460 if version >= 0 {
461 out.unaligned_records = {
462 let __rb_slice = if flex {
463 get_compact_bytes_borrowed(buf)?
464 } else {
465 get_bytes_borrowed(buf)?
466 };
467 let mut __rb_cur = __rb_slice;
468 <crate::records::RecordsPayloadBorrowed as crate::DecodeBorrow>::decode_borrow(
469 &mut __rb_cur,
470 version,
471 )?
472 };
473 }
474 if flex {
475 let mut tag_current_leader = None;
476 out.unknown_tagged_fields = read_tagged_fields(buf, |tag, payload| match tag {
477 0 => {
478 tag_current_leader = Some({
479 let b: &mut &[u8] = payload;
480 LeaderIdAndEpoch::decode_borrow(b, version)?
481 });
482 Ok(true)
483 }
484 _ => Ok(false),
485 })?;
486 if let Some(v) = tag_current_leader {
487 out.current_leader = v;
488 }
489 }
490 Ok(out)
491 }
492}
493#[cfg(test)]
494impl PartitionSnapshot<'_> {
495 #[must_use]
496 pub fn populated(version: i16) -> Self {
497 let mut m = Self::default();
498 if version >= 0 {
499 m.index = 1i32;
500 }
501 if version >= 0 {
502 m.error_code = 1i16;
503 }
504 if version >= 0 {
505 m.snapshot_id = SnapshotId::populated(version);
506 }
507 if version >= 0 {
508 m.size = 1i64;
509 }
510 if version >= 0 {
511 m.position = 1i64;
512 }
513 if version >= 0 {
514 m.current_leader = LeaderIdAndEpoch::populated(version);
515 }
516 m
517 }
518}
519#[derive(Debug, Clone, PartialEq, Eq, Default)]
520pub struct SnapshotId {
521 pub end_offset: i64,
522 pub epoch: i32,
523 pub unknown_tagged_fields: UnknownTaggedFields,
524}
525impl SnapshotId {
526 pub fn to_owned(&self) -> crate::owned::fetch_snapshot_response::SnapshotId {
527 crate::owned::fetch_snapshot_response::SnapshotId {
528 end_offset: (self.end_offset),
529 epoch: (self.epoch),
530 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
531 }
532 }
533}
534impl Encode for SnapshotId {
535 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
536 let flex = version >= 0;
537 if version >= 0 {
538 put_i64(buf, self.end_offset);
539 }
540 if version >= 0 {
541 put_i32(buf, self.epoch);
542 }
543 if flex {
544 let tagged = WriteTaggedFields::new();
545 tagged.write(buf, &self.unknown_tagged_fields);
546 }
547 Ok(())
548 }
549 fn encoded_len(&self, version: i16) -> usize {
550 let flex = version >= 0;
551 let mut n: usize = 0;
552 if version >= 0 {
553 n += 8;
554 }
555 if version >= 0 {
556 n += 4;
557 }
558 if flex {
559 let known_pairs: Vec<(u32, usize)> = Vec::new();
560 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
561 }
562 n
563 }
564}
565impl<'de> DecodeBorrow<'de> for SnapshotId {
566 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
567 let flex = version >= 0;
568 let mut out = Self::default();
569 if version >= 0 {
570 out.end_offset = get_i64(buf)?;
571 }
572 if version >= 0 {
573 out.epoch = get_i32(buf)?;
574 }
575 if flex {
576 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
577 }
578 Ok(out)
579 }
580}
581#[cfg(test)]
582impl SnapshotId {
583 #[must_use]
584 pub fn populated(version: i16) -> Self {
585 let mut m = Self::default();
586 if version >= 0 {
587 m.end_offset = 1i64;
588 }
589 if version >= 0 {
590 m.epoch = 1i32;
591 }
592 m
593 }
594}
595#[derive(Debug, Clone, PartialEq, Eq, Default)]
596pub struct LeaderIdAndEpoch {
597 pub leader_id: i32,
598 pub leader_epoch: i32,
599 pub unknown_tagged_fields: UnknownTaggedFields,
600}
601impl LeaderIdAndEpoch {
602 pub fn to_owned(&self) -> crate::owned::fetch_snapshot_response::LeaderIdAndEpoch {
603 crate::owned::fetch_snapshot_response::LeaderIdAndEpoch {
604 leader_id: (self.leader_id),
605 leader_epoch: (self.leader_epoch),
606 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
607 }
608 }
609}
610impl Encode for LeaderIdAndEpoch {
611 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
612 let flex = version >= 0;
613 if version >= 0 {
614 put_i32(buf, self.leader_id);
615 }
616 if version >= 0 {
617 put_i32(buf, self.leader_epoch);
618 }
619 if flex {
620 let tagged = WriteTaggedFields::new();
621 tagged.write(buf, &self.unknown_tagged_fields);
622 }
623 Ok(())
624 }
625 fn encoded_len(&self, version: i16) -> usize {
626 let flex = version >= 0;
627 let mut n: usize = 0;
628 if version >= 0 {
629 n += 4;
630 }
631 if version >= 0 {
632 n += 4;
633 }
634 if flex {
635 let known_pairs: Vec<(u32, usize)> = Vec::new();
636 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
637 }
638 n
639 }
640}
641impl<'de> DecodeBorrow<'de> for LeaderIdAndEpoch {
642 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
643 let flex = version >= 0;
644 let mut out = Self::default();
645 if version >= 0 {
646 out.leader_id = get_i32(buf)?;
647 }
648 if version >= 0 {
649 out.leader_epoch = get_i32(buf)?;
650 }
651 if flex {
652 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
653 }
654 Ok(out)
655 }
656}
657#[cfg(test)]
658impl LeaderIdAndEpoch {
659 #[must_use]
660 pub fn populated(version: i16) -> Self {
661 let mut m = Self::default();
662 if version >= 0 {
663 m.leader_id = 1i32;
664 }
665 if version >= 0 {
666 m.leader_epoch = 1i32;
667 }
668 m
669 }
670}
671#[derive(Debug, Clone, PartialEq, Eq, Default)]
672pub struct NodeEndpoint<'a> {
673 pub node_id: i32,
674 pub host: &'a str,
675 pub port: u16,
676 pub unknown_tagged_fields: UnknownTaggedFields,
677}
678impl NodeEndpoint<'_> {
679 pub fn to_owned(&self) -> crate::owned::fetch_snapshot_response::NodeEndpoint {
680 crate::owned::fetch_snapshot_response::NodeEndpoint {
681 node_id: (self.node_id),
682 host: (self.host).to_string(),
683 port: (self.port),
684 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
685 }
686 }
687}
688impl Encode for NodeEndpoint<'_> {
689 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
690 let flex = version >= 0;
691 if version >= 1 {
692 put_i32(buf, self.node_id);
693 }
694 if version >= 1 {
695 if flex {
696 put_compact_string(buf, self.host);
697 } else {
698 put_string(buf, self.host);
699 }
700 }
701 if version >= 1 {
702 put_u16(buf, self.port);
703 }
704 if flex {
705 let tagged = WriteTaggedFields::new();
706 tagged.write(buf, &self.unknown_tagged_fields);
707 }
708 Ok(())
709 }
710 fn encoded_len(&self, version: i16) -> usize {
711 let flex = version >= 0;
712 let mut n: usize = 0;
713 if version >= 1 {
714 n += 4;
715 }
716 if version >= 1 {
717 n += if flex {
718 compact_string_len(self.host)
719 } else {
720 string_len(self.host)
721 };
722 }
723 if version >= 1 {
724 n += 2;
725 }
726 if flex {
727 let known_pairs: Vec<(u32, usize)> = Vec::new();
728 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
729 }
730 n
731 }
732}
733impl<'de> DecodeBorrow<'de> for NodeEndpoint<'de> {
734 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
735 let flex = version >= 0;
736 let mut out = Self::default();
737 if version >= 1 {
738 out.node_id = get_i32(buf)?;
739 }
740 if version >= 1 {
741 out.host = if flex {
742 get_compact_string_borrowed(buf)?
743 } else {
744 get_string_borrowed(buf)?
745 };
746 }
747 if version >= 1 {
748 out.port = get_u16(buf)?;
749 }
750 if flex {
751 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
752 }
753 Ok(out)
754 }
755}
756#[cfg(test)]
757impl NodeEndpoint<'_> {
758 #[must_use]
759 pub fn populated(version: i16) -> Self {
760 let mut m = Self::default();
761 if version >= 1 {
762 m.node_id = 1i32;
763 }
764 if version >= 1 {
765 m.host = "x";
766 }
767 if version >= 1 {
768 m.port = 1u16;
769 }
770 m
771 }
772}