1use crate::backend::MkGpuBackend;
4
5pub struct MkStagingBuffer<B: MkGpuBackend> {
7 handle: B::BufferHandle,
8 size: usize,
9}
10
11impl<B: MkGpuBackend> MkStagingBuffer<B> {
12 pub(crate) fn new(handle: B::BufferHandle, size: usize) -> Self {
14 Self { handle, size }
15 }
16
17 pub fn size(&self) -> usize {
19 self.size
20 }
21
22 pub fn handle(&self) -> &B::BufferHandle {
24 &self.handle
25 }
26}
27
28#[derive(Debug)]
30pub enum StagingError {
31 DataTooLarge,
32 NotMapped,
33 MapFailed,
34}
35
36impl std::fmt::Display for StagingError {
37 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38 match self {
39 StagingError::DataTooLarge => write!(f, "Data too large for staging buffer"),
40 StagingError::NotMapped => write!(f, "Buffer not mapped"),
41 StagingError::MapFailed => write!(f, "Failed to map buffer"),
42 }
43 }
44}
45
46impl std::error::Error for StagingError {}