mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
ignore wasm compilation target
This commit is contained in:
parent
26152e07e5
commit
30e4a70d07
3 changed files with 66 additions and 1 deletions
|
@ -20,7 +20,7 @@ fs = []
|
|||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
io-uring = "0.6.1"
|
||||
|
||||
[target.'cfg(not(target_os = "linux"))'.dependencies]
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
polling = "3.7.2"
|
||||
rustix = "0.38.34"
|
||||
|
||||
|
|
60
core/io/generic.rs
Normal file
60
core/io/generic.rs
Normal file
|
@ -0,0 +1,60 @@
|
|||
use super::{Completion, File, WriteCompletion, IO};
|
||||
use anyhow::{Ok, Result};
|
||||
use log::trace;
|
||||
use std::cell::RefCell;
|
||||
use std::io::{Read, Seek, Write};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct GenericIO {}
|
||||
|
||||
impl GenericIO {
|
||||
pub fn new() -> Result<Self> {
|
||||
Ok(Self {})
|
||||
}
|
||||
}
|
||||
|
||||
impl IO for GenericIO {
|
||||
fn open_file(&self, path: &str) -> Result<Rc<dyn File>> {
|
||||
trace!("open_file(path = {})", path);
|
||||
let file = std::fs::File::open(path)?;
|
||||
Ok(Rc::new(GenericFile {
|
||||
file: RefCell::new(file),
|
||||
}))
|
||||
}
|
||||
|
||||
fn run_once(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GenericFile {
|
||||
file: RefCell<std::fs::File>,
|
||||
}
|
||||
|
||||
impl File for GenericFile {
|
||||
fn pread(&self, pos: usize, c: Rc<Completion>) -> Result<()> {
|
||||
let mut file = self.file.borrow_mut();
|
||||
file.seek(std::io::SeekFrom::Start(pos as u64))?;
|
||||
{
|
||||
let mut buf = c.buf_mut();
|
||||
let buf = buf.as_mut_slice();
|
||||
file.read_exact(buf)?;
|
||||
}
|
||||
c.complete();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pwrite(
|
||||
&self,
|
||||
pos: usize,
|
||||
buffer: Rc<RefCell<crate::Buffer>>,
|
||||
c: Rc<WriteCompletion>,
|
||||
) -> Result<()> {
|
||||
let mut file = self.file.borrow_mut();
|
||||
file.seek(std::io::SeekFrom::Start(pos as u64))?;
|
||||
let buf = buffer.borrow();
|
||||
let buf = buf.as_slice();
|
||||
file.write_all(buf)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -128,4 +128,9 @@ cfg_block! {
|
|||
mod windows;
|
||||
pub use windows::WindowsIO as PlatformIO;
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))] {
|
||||
mod generic;
|
||||
pub use generic::GenericIO as PlatformIO;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue