Skip to main content

Crate mtl_sys

Crate mtl_sys 

Source
Expand description

Low-level Objective-C runtime bindings for Metal.

This crate provides the foundational FFI layer for communicating with the Objective-C runtime. It includes:

  • Architecture-aware message sending (objc_msgSend variants)
  • Selector and class caching
  • Objective-C block support (Clang ABI)
  • Custom macros for enums and bitflags

§Safety

This crate is intentionally unsafe. All public functions are marked unsafe and require the caller to uphold Objective-C runtime invariants. Higher-level safe wrappers are provided by the metal crate.

Macros§

class
Cached class lookup.
metal_enum
Define a Metal enum type.
metal_options
Define a Metal options/bitflags type.
sel
Cached selector lookup.

Structs§

BlockLiteral
Block literal structure matching Clang’s Block_literal_1.
CachedClass
Helper type for caching classes.
CachedSel
Helper type for caching selectors.
Class
Objective-C class.
HeapOneArgBlock
A heap-allocated one-argument block that can be safely passed to ObjC APIs.
MethodDescription
Objective-C method description (for protocol methods).
Protocol
Objective-C protocol.
RcBlock
A reference-counted block wrapping a Rust closure.
Sel
Objective-C selector.

Enums§

IOCompressionMethod
IO compression method.
IOCompressionStatus
IO compression status.

Functions§

MTLCopyAllDevices
Copy all available Metal devices.
MTLCopyAllDevicesWithObserver
Copy all devices with a notification observer.
MTLCreateSystemDefaultDevice
Create the system default Metal device.
MTLIOCompressionContextAppendData
Append data to a compression context.
MTLIOCompressionContextDefaultChunkSize
Get the default chunk size for IO compression.
MTLIOCreateCompressionContext
Create an IO compression context.
MTLIOFlushAndDestroyCompressionContext
Flush and destroy a compression context.
MTLRemoveDeviceObserver
Remove a device observer.
copy_all_devices
Safely copy all available Metal devices (macOS only).
create_system_default_device
Safely create the system default Metal device.
get_protocol
Look up a protocol by name.
io_compression_default_chunk_size
Get the default IO compression chunk size.
msg_send_0
Send a message with no arguments.
msg_send_1
Send a message with 1 argument.
msg_send_2
Send a message with 2 arguments.
msg_send_3
Send a message with 3 arguments.
msg_send_4
Send a message with 4 arguments.
msg_send_5
Send a message with 5 arguments.
msg_send_6
Send a message with 6 arguments.
msg_send_7
Send a message with 7 arguments.
msg_send_8
Send a message with 8 arguments.
msg_send_9
Send a message with 9 arguments.
msg_send_10
Send a message with 10 arguments.

Type Aliases§

CommandBufferHandler
Handler for command buffer completion.
DeallocatorBlock
Block type: void (^)(void*, size_t)
DeviceNotificationHandler
Handler for device notifications.
DeviceObserver
Opaque type for device observers (used with hot-plug notifications).
DrawablePresentedHandler
Handler for drawable presentation.
EventBlock
Block type: void (^)(id, uint64_t)
IOCompressionContext
Opaque compression context handle.
LogHandlerBlock
Block type: void (^)(id, id, isize, id)
NewComputePipelineStateCompletionHandler
Completion handler for compute pipeline state creation.
NewComputePipelineStateWithReflectionCompletionHandler
Completion handler for compute pipeline state with reflection.
NewLibraryCompletionHandler
Completion handler for library creation.
NewRenderPipelineStateCompletionHandler
Completion handler for render pipeline state creation.
NewRenderPipelineStateWithReflectionCompletionHandler
Completion handler for render pipeline state with reflection.
OneArgBlock
Block type: void (^)(id)
SharedEventNotificationHandler
Handler for SharedEvent notifications.
ThreeArgBlock
Block type: void (^)(id, id, id)
TwoArgBlock
Block type: void (^)(id, id)
VoidBlock
Block type: void (^)(void)