Docs.rs
  • objc2-encode-4.1.0
    • objc2-encode 4.1.0
    • Permalink
    • Docs.rs crate page
    • MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • simlay
    • madsmtm
    • Dependencies
    • Versions
    • 100% of the crate is documented
  • Platform
    • aarch64-apple-darwin
    • aarch64-apple-ios
    • aarch64-apple-ios-macabi
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate objc2_encode

objc2_encode4.1.0

  • All Items

Sections

  • Objective-C type-encoding
    • Example
    • Further resources

Crate Items

  • Structs
  • Enums

Crates

  • objc2_encode

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

  • Objective-C, Encoding and You.
  • Apple’s documentation on Type Encodings.
  • How are the digits in ObjC method type encoding calculated?
  • clang’s source code for generating @encode.

Structs§

ParseError
The error that was encountered while parsing an encoding string.

Enums§

Encoding
An Objective-C type-encoding.
EncodingBox
The boxed version of Encoding.

Results

Settings
Help
    enum
    objc2_encode::EncodingBox
    The boxed version of Encoding.
    method
    objc2_encode::EncodingBox::clone
    &EncodingBox -> EncodingBox
    method
    objc2_encode::Encoding::eq
    &Encoding, &EncodingBox -> bool
    method
    objc2_encode::EncodingBox::eq
    &EncodingBox, &EncodingBox -> bool
    method
    objc2_encode::Encoding::equivalent_to_box
    &Encoding, &EncodingBox -> bool
    Check if an encoding is equivalent to a boxed encoding.
    method
    objc2_encode::EncodingBox::fmt
    &EncodingBox, &mut Formatter -> Result
    method
    objc2_encode::EncodingBox::hash
    &EncodingBox, &mut __H -> ()
    method
    objc2_encode::EncodingBox::from_str
    &str -> Result<EncodingBox, FromStr::Err>
    method
    objc2_encode::EncodingBox::from_start_of_str
    &mut &str -> Result<EncodingBox, ParseError>
    Parse and consume an encoding from the start of a string.
    method
    objc2_encode::EncodingBox::clone
    &EncodingBox -> EncodingBox