Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mapping for Sequence Types

Bounded and unbounded IDL sequence types are mapped to Vec in Rust.

// IDL
typedef sequence<T> V1;
typedef sequence<T, 2> V2;
typedef sequence<V1> V3;
#![allow(unused)]
fn main() {
// Rust
type V1 = Vec<T>;
type V2 = Vec<T>;
type V3 = Vec<V1>;
}

Default Value

The default value for a sequence is an empty vector:

#![allow(unused)]
fn main() {
Vec::new()
}

Bounded Sequences

IDL allows specifying a maximum size for sequences. This bound is not enforced at the type level in Rust, but is checked during serialization. An implementation may choose to provide a custom BoundedVec<T, N> type for such purposes.

// IDL
typedef sequence<int32, 100> BoundedSeq;
#![allow(unused)]
fn main() {
// Rust - bound is not reflected in the type
pub type BoundedSeq = Vec<i32>;
}