Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/gpu/metal/objc"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
mem |
core/mem |
objc.dodo |
ptr |
core/ptr |
objc.dodo |
Id
Type alias · Source
An object, class or selector pointer as the runtime passes it.
pub type Id = *mut u8
Range
Struct · Source
NSRange: a span of UTF-16 units or array elements.
@repr(C)
pub struct Range {
pub location: usize
pub length: usize
}
Range.new
Function · Source
pub fn new(location: usize, length: usize) -> Range
class
Function · Source
The class with this NUL-terminated name, if the process has loaded it.
pub fn class(name: &[u8]) -> Option<Id>
selector
Function · Source
The selector with this NUL-terminated name, such as b“length\0”. Returns none for a name without exactly one terminating NUL.
pub fn selector(name: &[u8]) -> Option<Id>
cached_selector
Function · Source
Look up a selector once and keep it in
slot, a static initialized to 0. Racing threads store the same value, so relaxed atomics suffice.Safety:
slotaddresses a live, aligned usize used only for this name, andnameends in its only NUL.
pub unsafe fn cached_selector(slot: *mut usize, name: &[u8]) -> Id
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
cached_class
Function · Source
Look up a class once and keep it in
slot, a static initialized to 0. Returns null if the class is not loaded; a later call looks again.Safety: as for cached_selector.
pub unsafe fn cached_class(slot: *mut usize, name: &[u8]) -> Id
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
Object
Struct · Source
An owned strong reference to an Objective-C object. Never null.
pub struct Object {
// Private implementation fields omitted.
}
Object.from_retained
Function · Source
Adopt a reference the caller owns, such as the result of a method whose name begins with alloc, new, copy or mutableCopy. Returns none for nil, which needs no release.
Safety:
idis nil or an object whose +1 reference is transferred.
pub unsafe fn from_retained(id: Id) -> Option<Object>
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
Object.retain
Function · Source
Retain an object the caller does not own, such as most getters’ results. Returns none for nil.
Safety:
idis nil or a live object.
pub unsafe fn retain(id: Id) -> Option<Object>
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
Object.as_ptr
Function · Source
The object pointer, for sending messages. It stays valid while self is alive; the caller must not release it.
pub fn as_ptr(&self) -> Id
Object.clone
Function · Source
Another strong reference to the same object.
pub fn clone(&self) -> Object
Object.into_retained
Function · Source
Give up ownership without releasing: the caller now owns the +1 reference and must eventually release it.
pub fn into_retained(self) -> Id
Object.same
Function · Source
Whether both reference the same object.
pub fn same(&self, other: &Object) -> bool
Object.is_kind_of
Function · Source
Whether the object is an instance of the class or a subclass.
pub fn is_kind_of(&self, class: Id) -> bool
AutoreleasePool
Struct · Source
Collects autoreleased objects until dropped. Pools nest: drop them in the reverse order of creation, on the thread that created them.
pub struct AutoreleasePool {
// Private implementation fields omitted.
}
AutoreleasePool.new
Function · Source
pub fn new() -> AutoreleasePool
get_object
Function · Source
Send a getter returning an unowned object and retain the result.
Safety:
receiveris live andselectornames a method taking no arguments and returning an object or nil.
pub unsafe fn get_object(receiver: Id, selector: Id) -> Option<Object>
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
NSString
Struct · Source
An immutable NSString.
pub struct NSString {
// Private implementation fields omitted.
}
NSString.new
Function · Source
A copy of
text. Returns none if Foundation is not loaded or the allocation fails.
pub fn new(text: &str) -> Option<NSString>
NSString.from_object
Function · Source
Wrap an object known to be an NSString.
Safety:
objectis an NSString or a subclass.
pub unsafe fn from_object(object: Object) -> NSString
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
NSString.as_object
Function · Source
pub fn as_object(&self) -> &Object
NSString.len
Function · Source
The length in UTF-8 bytes.
pub fn len(&self) -> usize
NSString.copy_to
Function · Source
Copy the UTF-8 text into
outand return the number of bytes written. A longer string is cut at the last whole character that fits, so the copied bytes are always valid UTF-8.
pub fn copy_to(&self, out: &mut[u8]) -> usize
NSString.equals
Function · Source
Whether the string’s text equals
text.
pub fn equals(&self, text: &str) -> bool
NSError
Struct · Source
An NSError: what failed, as a domain, a code and a readable message. Shader compilation errors carry the compiler’s whole log as the message.
pub struct NSError {
// Private implementation fields omitted.
}
NSError.from_object
Function · Source
Safety:
objectis an NSError or a subclass.
pub unsafe fn from_object(object: Object) -> NSError
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
NSError.as_object
Function · Source
pub fn as_object(&self) -> &Object
NSError.code
Function · Source
pub fn code(&self) -> isize
NSError.domain
Function · Source
The error domain, such as MTLLibraryErrorDomain.
pub fn domain(&self) -> Option<NSString>
NSError.message
Function · Source
The localized description.
pub fn message(&self) -> Option<NSString>
NSArray
Struct · Source
An immutable NSArray of objects.
pub struct NSArray {
// Private implementation fields omitted.
}
NSArray.from_object
Function · Source
Safety:
objectis an NSArray or a subclass.
pub unsafe fn from_object(object: Object) -> NSArray
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
NSArray.as_object
Function · Source
pub fn as_object(&self) -> &Object
NSArray.len
Function · Source
pub fn len(&self) -> usize
NSArray.get
Function · Source
A strong reference to the element at
index, or none past the end.
pub fn get(&self, index: usize) -> Option<Object>