zpp-2022-rust-seastar / seastar-rs

Idiomatic Rust bindings to the Seastar framework
6 stars 3 forks source link

Expose basic file I/O #41

Closed grzenow4 closed 1 year ago

grzenow4 commented 1 year ago

Fixes: #39 Depends on: #24 #27

This PR introduces structs OpenOptions and File

#[derive(Clone)]
pub struct OpenOptions {
    read: bool,
    write: bool,
    create: bool,
}

pub struct File {
    inner: UniquePtr<file_t>,
}

which allow for basic I/O operations such as read and write to a file. All the introduced methods are:

Reading and writing to a file is done via DmaBuffer struct:

const ALIGN: usize = 512;
const CHUNK_SIZE: usize = 4096;

pub struct DmaBuffer {
    buffer: *mut u8,
    size: usize,
}