virtual_file_system/
lib.rs1#![no_std]
2
3extern crate alloc;
4
5mod directory;
6mod error;
7mod file;
8mod file_system;
9mod hierarchy;
10mod item;
11mod r#macro;
12mod pipe;
13mod synchronous_directory;
14mod synchronous_file;
15
16pub use directory::*;
17pub use error::*;
18use exported_file_system::{Flags, StateFlags};
19pub use file::*;
20pub use file_system::*;
21pub use hierarchy::*;
22pub use item::*;
23pub use synchronous_directory::*;
24pub use synchronous_file::*;
25
26pub extern crate file_system as exported_file_system;
27
28pub async fn poll<O>(mut operation: impl FnMut() -> Result<O>) -> Result<O> {
29 loop {
30 match operation() {
31 Err(Error::FileSystem(::file_system::Error::RessourceBusy))
32 | Err(Error::RessourceBusy) => {
33 task::yield_now().await;
34 }
35 other => return other,
36 }
37 }
38}
39
40pub fn blocking_operation<O>(flags: Flags, mut operation: impl FnMut() -> Result<O>) -> Result<O> {
41 let non_blocking = flags.get_state().contains(StateFlags::NonBlocking);
42
43 loop {
44 match operation() {
45 Err(Error::FileSystem(::file_system::Error::RessourceBusy))
46 | Err(Error::RessourceBusy) => {
47 if non_blocking {
48 return Err(Error::FileSystem(::file_system::Error::RessourceBusy));
49 }
50 }
51 other => return other,
52 }
53 }
54}