Skip to main content

async_fuser/ll/reply_async/
data.rs

1//! Response data implementation for operations that return an arbitrary byte
2//! buffer.
3
4use std::io::IoSlice;
5
6use crate::ll::{ioslice_concat::IosliceConcat, reply::Response};
7
8/// Response data from async operations that return a byte buffer.
9#[derive(Debug)]
10pub struct DataResponse {
11    data: Vec<u8>,
12}
13
14impl DataResponse {
15    /// Creates a new [`DataResponse`] with the provided bytes.
16    pub fn new(data: Vec<u8>) -> Self {
17        Self { data }
18    }
19
20    fn bytes(&self) -> &[u8] {
21        self.data.as_slice()
22    }
23}
24
25impl Response for DataResponse {
26    fn payload(&self) -> impl IosliceConcat {
27        [IoSlice::new(self.bytes())]
28    }
29}