use crate::raw::{
cl_mem_flags, CL_MEM_ALLOC_HOST_PTR, CL_MEM_HOST_NO_ACCESS, CL_MEM_HOST_READ_ONLY,
CL_MEM_HOST_WRITE_ONLY, CL_MEM_READ_ONLY, CL_MEM_READ_WRITE, CL_MEM_WRITE_ONLY,
};
mod sealed {
use crate::raw::cl_mem_flags;
pub trait FlagInternal {
const FLAGS: cl_mem_flags;
}
}
pub trait HostAccess: sealed::FlagInternal {}
pub trait HostReadable: HostAccess {}
pub trait HostWritable: HostAccess {}
pub struct HostNoAccess;
pub struct HostReadOnly;
pub struct HostWriteOnly;
pub struct HostReadWrite;
impl sealed::FlagInternal for HostNoAccess {
const FLAGS: cl_mem_flags = CL_MEM_HOST_NO_ACCESS;
}
impl sealed::FlagInternal for HostReadOnly {
const FLAGS: cl_mem_flags = CL_MEM_HOST_READ_ONLY;
}
impl sealed::FlagInternal for HostWriteOnly {
const FLAGS: cl_mem_flags = CL_MEM_HOST_WRITE_ONLY;
}
impl sealed::FlagInternal for HostReadWrite {
const FLAGS: cl_mem_flags = 0;
}
impl HostAccess for HostNoAccess {}
impl HostAccess for HostReadOnly {}
impl HostReadable for HostReadOnly {}
impl HostAccess for HostWriteOnly {}
impl HostWritable for HostWriteOnly {}
impl HostAccess for HostReadWrite {}
impl HostReadable for HostReadWrite {}
impl HostWritable for HostReadWrite {}
pub trait DeviceAccess: sealed::FlagInternal {}
pub struct DeviceReadOnly;
pub struct DeviceWriteOnly;
pub struct DeviceReadWrite;
impl sealed::FlagInternal for DeviceReadOnly {
const FLAGS: cl_mem_flags = CL_MEM_READ_ONLY;
}
impl sealed::FlagInternal for DeviceWriteOnly {
const FLAGS: cl_mem_flags = CL_MEM_WRITE_ONLY;
}
impl sealed::FlagInternal for DeviceReadWrite {
const FLAGS: cl_mem_flags = CL_MEM_READ_WRITE;
}
impl DeviceAccess for DeviceReadOnly {}
impl DeviceAccess for DeviceWriteOnly {}
impl DeviceAccess for DeviceReadWrite {}
pub trait BufferFlags: sealed::FlagInternal {}
pub struct NoFlags;
pub struct AllocHostPtr;
impl sealed::FlagInternal for NoFlags {
const FLAGS: cl_mem_flags = 0;
}
impl sealed::FlagInternal for AllocHostPtr {
const FLAGS: cl_mem_flags = CL_MEM_ALLOC_HOST_PTR;
}
impl BufferFlags for NoFlags {}
impl BufferFlags for AllocHostPtr {}