fuse_backend_rs/common/mod.rs
1// Copyright (C) 2022 Alibaba Cloud. All rights reserved.
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! Some utilities to support fuse-backend-rs.
6//!
7//! ### Wrappers for Rust async io
8//! It's challenging to support Rust async io, and it's even more challenging to support Rust async io with Linux io-uring.
9//!
10//! This `common` module adds a wrapper layer over [tokio](https://github.com/tokio-rs/tokio) and [tokio-uring](https://github.com/tokio-rs/tokio-uring) to simplify the way to support Rust async io by providing:
11//! - [FileReadWriteVolatile](https://github.com/dragonflyoss/image-service): A trait similar to [std::io::Read] and [std::io::Write], but uses [FileVolatileSlice](https://github.com/dragonflyoss/image-service) objects as data buffers.
12//! - [FileVolatileSlice](crate::buf::FileVolatileSlice): An adapter structure to work around limitations of the [vm-memory](https://github.com/rust-vmm/vm-memory) crate.
13//! - [FileVolatileBuf](crate::buf::FileVolatileBuf): An adapter structure to support [io-uring](https://github.com/tokio-rs/io-uring) based asynchronous IO.
14//! - [File](crate::async_file::File): An adapter for for [tokio::fs::File] and [tokio-uring::fs::File].
15//! - [Runtime](crate::async_runtime::Runtime): An adapter for for [tokio::runtime::Runtime] and [tokio-uring::Runtime].
16
17pub mod file_buf;
18pub mod file_traits;
19
20#[cfg(feature = "async-io")]
21pub mod async_file;
22#[cfg(feature = "async-io")]
23pub mod async_runtime;
24#[cfg(feature = "async-io")]
25pub mod mpmc;
26
27#[cfg(target_os = "linux")]
28#[doc(hidden)]
29pub use libc::{off64_t, pread64, preadv64, pwrite64, pwritev64};
30#[cfg(target_os = "macos")]
31#[doc(hidden)]
32pub use libc::{
33 off_t as off64_t, pread as pread64, preadv as preadv64, pwrite as pwrite64,
34 pwritev as pwritev64,
35};