objc2_metal/
types.rs

1use crate::MTLResourceID;
2
3impl MTLResourceID {
4    /// Construct a `MTLResourceID` from an ID previously gotten via `to_raw`.
5    ///
6    /// # Safety
7    ///
8    /// The documentation for `MTLResourceID` says:
9    ///
10    /// > A MTLResourceID represents a specific GPU resource, mutating this
11    /// > handle is undefined unless the mutation results in the value
12    /// > equalling an already existing handle of the same resource type.
13    ///
14    /// So we've tentatively marked this method as `unsafe`, with the safety
15    /// requirement that the ID must be valid, i.e. have previously come from
16    /// [`to_raw`][Self::to_raw] or similar.
17    ///
18    /// If you disagree with this assessment, feel free to open an issue!
19    pub const unsafe fn from_raw(id: u64) -> Self {
20        Self { _impl: id }
21    }
22
23    /// Get the underlying data of the ID.
24    ///
25    /// May be useful for FFI purposes.
26    pub const fn to_raw(self) -> u64 {
27        self._impl
28    }
29}