Skip to main content

poulpy_hal/delegates/
scratch.rs

1use crate::{
2    api::{ScratchAvailable, ScratchOwnedAlloc, ScratchOwnedBorrow},
3    layouts::{Backend, ScratchArena, ScratchOwned},
4};
5
6impl<B> ScratchOwnedAlloc<B> for ScratchOwned<B>
7where
8    B: Backend,
9{
10    fn alloc(size: usize) -> Self {
11        ScratchOwned {
12            data: B::alloc_bytes(size),
13            _phantom: std::marker::PhantomData,
14        }
15    }
16}
17
18impl<B> ScratchOwnedBorrow<B> for ScratchOwned<B>
19where
20    B: Backend,
21{
22    fn borrow(&mut self) -> ScratchArena<'_, B> {
23        self.arena()
24    }
25}
26
27impl<B: Backend> ScratchAvailable for ScratchArena<'_, B> {
28    fn available(&self) -> usize {
29        ScratchArena::available(self)
30    }
31}