fluvio_future/
file_slice.rs

1use std::os::unix::io::AsRawFd;
2use std::os::unix::io::RawFd;
3
4/// Slice of the file
5/// This works only on raw fd
6#[derive(Default, Debug, Clone)]
7pub struct AsyncFileSlice {
8    fd: RawFd,
9    position: u64,
10    len: u64,
11}
12
13impl AsyncFileSlice {
14    pub fn new(fd: RawFd, position: u64, len: u64) -> Self {
15        Self { fd, position, len }
16    }
17
18    pub fn position(&self) -> u64 {
19        self.position
20    }
21
22    pub fn len(&self) -> u64 {
23        self.len
24    }
25
26    pub fn is_empty(&self) -> bool {
27        self.len == 0
28    }
29
30    pub fn fd(&self) -> RawFd {
31        self.fd
32    }
33}
34
35impl AsRawFd for AsyncFileSlice {
36    fn as_raw_fd(&self) -> RawFd {
37        self.fd
38    }
39}