pub trait Allocation {
// Required method
fn allocated_size(&self) -> UInteger;
}Expand description
Protocol for types that track their allocated memory size.
C++ equivalent: MTL::Allocation
This trait corresponds to the Objective-C protocol that all Metal resource
types conform to. In Rust, concrete types like Buffer,
Texture, and Heap implement this
method directly.
§Example
ⓘ
// All resource types have allocated_size() directly
let buffer = device.new_buffer(1024, ResourceOptions::default()).unwrap();
println!("Allocated: {} bytes", buffer.allocated_size());Required Methods§
Sourcefn allocated_size(&self) -> UInteger
fn allocated_size(&self) -> UInteger
Get the allocated size of this resource in bytes.
This may be larger than the requested size due to alignment requirements.
C++ equivalent: NS::UInteger allocatedSize() const