Find
C
ase-sensitive
R
egexp search
Path
firefox-main
/
third_party
/
rust
/
objc2-encode
/
src
Navigation
Enable keyboard shortcuts
Name
Description
Size
encoding.rs
25534
encoding_box.rs
8325
helper.rs
17665
lib.rs
# 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. [`objc2`]: https://crates.io/crates/objc2 ## Example Parse an encoding from a string and compare it to a known encoding. ```rust 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); # Ok::<(), objc2_encode::ParseError>(()) ``` ## Further resources - [Objective-C, Encoding and You](https://dmaclach.medium.com/objective-c-encoding-and-you-866624cc02de). - [Apple's documentation on Type Encodings](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html). - [How are the digits in ObjC method type encoding calculated?](https://stackoverflow.com/a/11527925) - [`clang`'s source code for generating `@encode`](https://github.com/llvm/llvm-project/blob/fae0dfa6421ea6c02f86ba7292fa782e1e2b69d1/clang/lib/AST/ASTContext.cpp#L7500-L7850).
2255
parse.rs
Parsing encodings from their string representation.
20670
static_str.rs
7342