Expand description
Collection types for protobuf messages.
This module provides arena-allocated containers used by generated protobuf code:
RepeatedField<T>: A growable array for repeated fieldsString: UTF-8 string (equivalent to protobufstring)Bytes: Byte array (equivalent to protobufbytes)
These types are designed for arena allocation and do not implement Drop.
Memory is freed when the arena is dropped.
§Example
use protocrap::{arena::Arena, containers::{RepeatedField, String}};
use allocator_api2::alloc::Global;
let mut arena = Arena::new(&Global);
// RepeatedField for integers
let mut numbers = RepeatedField::<i32>::new();
numbers.push(1, &mut arena);
numbers.push(2, &mut arena);
assert_eq!(&numbers[..], &[1, 2]);
// String from a str
let s = String::from_str("hello", &mut arena);
assert_eq!(s.as_str(), "hello");Structs§
- Repeated
Field - Like
Vec<T>but arena-allocated and never drops elements. Only suitable for trivial (Copy) types. - String
- Arena-allocated UTF-8 string for protobuf
stringfields.
Type Aliases§
- Bytes
- Alias for
RepeatedField<u8>, used for protobufbytesfields.