Mapping for String Types
Both bounded and unbounded IDL string types are mapped to String from the
standard library.
// IDL
typedef string MyString;
typedef wstring MyWideString;
#![allow(unused)]
fn main() {
// Rust
pub type MyString = String;
pub type MyWideString = String;
}
Default Value
The default value for a string is an empty string:
#![allow(unused)]
fn main() {
String::new()
}
Bounded Strings
IDL allows specifying a maximum length for strings. This bound is not enforced
at the type level in Rust, but is checked during serialization. An
implementation may choose to provide a custom BoundedString<N> type for such
purposes.
// IDL
typedef string<100> BoundedString;
#![allow(unused)]
fn main() {
// Rust - bound is not reflected in the type
pub type BoundedString = String;
}
Wide String Types
The char type in Rust is always a UTF-8 character. The String type is only
a collection of chars; for that reason, both IDL strings and wide strings are
mapped to the String type in Rust.