use alloc::sync::Arc;
pub trait CommandScope<Raw: Copy> {
type Commands;
}
pub trait HndCtx<Scope: CommandScope<Raw>, Raw: Copy> {
type Ctx: Send + Sync + 'static + HndCtx<Scope, Raw>;
fn ctx(&self) -> Self::Ctx;
fn raw(&self) -> Raw;
fn commands(&self) -> &Arc<Scope::Commands>;
}
pub trait MakeHnd<Ctx, S>: Sized {
type Output;
unsafe fn hnd(self, ctx: &Ctx) -> Self::Output {
unsafe { self.hnd_with(ctx, || ()) }
}
unsafe fn hnd_with<Dep: Send + Sync + 'static>(
self,
ctx: &Ctx,
dep: impl FnOnce() -> Dep,
) -> Self::Output;
}
pub trait Extension<Target>: Sized {
type Output;
unsafe fn make(target: &Target) -> Self::Output;
}
pub trait MakeExt: Sized {
unsafe fn ext<Ext: Extension<Self>>(&self) -> Ext::Output {
unsafe { Ext::make(self) }
}
}
mod _hnd_scope {
use crate::RawHandle;
pub trait HndScope<Target: RawHandle> {
type Impl;
}
}
pub(crate) use _hnd_scope::*;