use core::ptr::NonNull;
use super::bitmap::BitmapRef;
use crate::ctypes::*;
#[derive(Debug)]
pub struct UnownedBitmapRef<'a> {
bref: BitmapRef,
_marker: core::marker::PhantomData<&'a u8>,
}
impl UnownedBitmapRef<'_> {
pub(crate) fn from_ptr<'a>(bitmap_ptr: NonNull<CBitmap>) -> UnownedBitmapRef<'a> {
UnownedBitmapRef {
bref: BitmapRef::from_ptr(bitmap_ptr),
_marker: core::marker::PhantomData,
}
}
}
impl Clone for UnownedBitmapRef<'_> {
fn clone(&self) -> Self {
UnownedBitmapRef::from_ptr(self.copy_non_null())
}
}
impl core::ops::Deref for UnownedBitmapRef<'_> {
type Target = BitmapRef;
fn deref(&self) -> &Self::Target {
&self.bref
}
}
impl AsRef<BitmapRef> for UnownedBitmapRef<'_> {
fn as_ref(&self) -> &BitmapRef {
self }
}
pub struct UnownedBitmapMut<'a> {
bref: UnownedBitmapRef<'a>,
}
impl UnownedBitmapMut<'_> {
pub(crate) fn from_ptr<'a>(bitmap_ptr: NonNull<CBitmap>) -> UnownedBitmapMut<'a> {
UnownedBitmapMut {
bref: UnownedBitmapRef::from_ptr(bitmap_ptr),
}
}
}
impl Clone for UnownedBitmapMut<'_> {
fn clone(&self) -> Self {
UnownedBitmapMut::from_ptr(self.copy_non_null())
}
}
impl core::ops::Deref for UnownedBitmapMut<'_> {
type Target = BitmapRef;
fn deref(&self) -> &Self::Target {
&self.bref.bref
}
}
impl core::ops::DerefMut for UnownedBitmapMut<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.bref.bref
}
}
impl AsRef<BitmapRef> for UnownedBitmapMut<'_> {
fn as_ref(&self) -> &BitmapRef {
self }
}
impl AsMut<BitmapRef> for UnownedBitmapMut<'_> {
fn as_mut(&mut self) -> &mut BitmapRef {
self }
}