[−][src]Module abi_stable::type_layout::tagging
Tag is a dynamically typed data structure used to encode extra properties about a type in its layout constant.
Comparison semantics
Tags don't use strict equality when doing layout checking , here is an exhaustive list on what is considered compatible for each variant in the interface:
-
Null: A Tag which is compatible with any other one. Note that Nulls are stripped from arrays,set,and map keys.
-
Integers/bools/strings: They must be strictly equal.
-
Arrays: They must have the same length, and have elements that compare equal.
-
Sets/Maps: The set/map in the interface must be a subset of the implementation,
Examples
Declaring a unit type with a tag.
use abi_stable::{tag,StableAbi}; #[repr(C)] #[derive(StableAbi)] #[sabi( tag = r##" tag!("WAT") "## )] struct UnitType;
Emulating const generics for strings
This emulates a const NAME:&'static str
parameter,
which is checked as being the same between the interface and implementation.
Structs
CheckableTag | A tag that can be checked for compatibility with another tag. |
FromLiteral | Used to convert many types to |
KeyValue | A key-value pair,used when constructing a map. |
Tag | Tag is a dynamically typed data structure used to encode extra properties about a type in its layout constant. |
TagErrors | The error produced when checking |
Enums
CTVariant | The possible variants of CheckableTag. |
Primitive | The primitive types of a variant,which do not contain other nested tags. |
TagVariant | All the Tag variants. |