Lines Matching defs:Opaque
271 /// [`Opaque<T>`] is meant to be used with FFI objects that are never interpreted by Rust code.
273 /// It is used to wrap structs from the C side, like for example `Opaque<bindings::mutex>`.
278 /// * The value is allowed to be mutated, when a `&Opaque<T>` exists on the Rust side.
279 /// * No uniqueness for mutable references: it is fine to have multiple `&mut Opaque<T>` point to
286 /// Using [`Opaque<T>`] allows to continue to use references on the Rust side even for values shared
293 /// use kernel::types::Opaque;
302 /// // `foo.val` is assumed to be handled on the C side, so we use `Opaque` to wrap it.
304 /// foo: Opaque<bindings::Foo>,
309 /// let ptr = Opaque::get(&self.foo);
316 /// // Create an instance of `Foo` with the `Opaque` wrapper.
318 /// foo: Opaque::new(bindings::Foo { val: 0xdb }),
324 pub struct Opaque<T> {
329 // SAFETY: `Opaque<T>` allows the inner value to be any bit pattern, including all zeros.
330 unsafe impl<T> Zeroable for Opaque<T> {}
332 impl<T> Opaque<T> {
360 /// `Opaque`. Since this memory is uninitialized, the closure is not allowed to read from it.
362 /// This function is safe, because the `T` inside of an `Opaque` is allowed to be
379 /// `Opaque`. Since this memory is uninitialized, the closure is not allowed to read from it.
381 /// This function is safe, because the `T` inside of an `Opaque` is allowed to be
407 /// The opposite operation of [`Opaque::cast_into`].
413 impl<T> Wrapper<T> for Opaque<T> {