Crate objc2_encode
source ·Expand description
§Objective-C type-encoding
The Objective-C directive @encode
encodes types as strings, and this is
used in various places in the runtime.
This crate provides the Encoding
type to describe and compare these
type-encodings, and the EncodingBox
type which does the same, except
it can be parsed from an encoding at runtime.
The types from this crate is exported under the objc2
crate as
objc2::encode
, so usually you would use it from there.
§Example
Parse an encoding from a string and compare it to a known encoding.
use objc2_encode::{Encoding, EncodingBox};
let s = "{s=i}";
let enc = Encoding::Struct("s", &[Encoding::Int]);
let parsed: EncodingBox = s.parse()?;
assert!(enc.equivalent_to_box(&parsed));
assert_eq!(enc.to_string(), s);
§Further resources
Structs§
- The error that was encountered while parsing an encoding string.
Enums§
- An Objective-C type-encoding.
- The boxed version of
Encoding
.