mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-31 05:44:25 +01:00
Use usize for truncate method in place of u64
This commit is contained in:
@@ -354,10 +354,10 @@ impl File for UringFile {
|
||||
Ok(self.file.metadata()?.len())
|
||||
}
|
||||
|
||||
fn truncate(&self, len: u64, c: Completion) -> Result<Arc<Completion>> {
|
||||
fn truncate(&self, len: usize, c: Completion) -> Result<Arc<Completion>> {
|
||||
let mut io = self.io.borrow_mut();
|
||||
let truncate = with_fd!(self, |fd| {
|
||||
io_uring::opcode::Ftruncate::new(fd, len)
|
||||
io_uring::opcode::Ftruncate::new(fd, len as u64)
|
||||
.build()
|
||||
.user_data(io.ring.get_key())
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@ impl File for MemoryFile {
|
||||
Ok(c)
|
||||
}
|
||||
|
||||
fn truncate(&self, len: u64, c: Completion) -> Result<Arc<Completion>> {
|
||||
fn truncate(&self, len: usize, c: Completion) -> Result<Arc<Completion>> {
|
||||
let new_size = len as usize;
|
||||
if new_size < self.size.get() {
|
||||
// Truncate pages
|
||||
|
||||
@@ -19,7 +19,7 @@ pub trait File: Send + Sync {
|
||||
-> Result<Completion>;
|
||||
fn sync(&self, c: Completion) -> Result<Completion>;
|
||||
fn size(&self) -> Result<u64>;
|
||||
fn truncate(&self, len: u64, c: Completion) -> Result<Arc<Completion>>;
|
||||
fn truncate(&self, len: usize, c: Completion) -> Result<Arc<Completion>>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
|
||||
@@ -452,9 +452,9 @@ impl File for UnixFile<'_> {
|
||||
}
|
||||
|
||||
#[instrument(err, skip_all, level = Level::INFO)]
|
||||
fn truncate(&self, len: u64, c: Completion) -> Result<Arc<Completion>> {
|
||||
fn truncate(&self, len: usize, c: Completion) -> Result<Arc<Completion>> {
|
||||
let file = self.file.borrow();
|
||||
let result = file.set_len(len);
|
||||
let result = file.set_len(len as u64);
|
||||
let c = Arc::new(c);
|
||||
match result {
|
||||
Ok(()) => {
|
||||
|
||||
@@ -166,7 +166,7 @@ impl File for VfsFileImpl {
|
||||
}
|
||||
}
|
||||
|
||||
fn truncate(&self, len: u64, c: Completion) -> Result<Arc<Completion>> {
|
||||
fn truncate(&self, len: usize, c: Completion) -> Result<Arc<Completion>> {
|
||||
if self.vfs.is_null() {
|
||||
return Err(LimboError::ExtensionError("VFS is null".to_string()));
|
||||
}
|
||||
|
||||
@@ -192,17 +192,17 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn #trunc_fn_name(file_ptr: *const ::std::ffi::c_void, len: i64) -> i32 {
|
||||
pub unsafe extern "C" fn #trunc_fn_name(file_ptr: *const ::std::ffi::c_void, len: i64) -> ::turso_ext::ResultCode {
|
||||
if file_ptr.is_null() {
|
||||
return -1;
|
||||
return ::turso_ext::ResultCode::Error;
|
||||
}
|
||||
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||
let file: &mut <#struct_name as ::turso_ext::VfsExtension>::File =
|
||||
&mut *(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||
if <#struct_name as ::turso_ext::VfsExtension>::File::truncate(file, len).is_err() {
|
||||
return -1;
|
||||
return ::turso_ext::ResultCode::Error;
|
||||
}
|
||||
0
|
||||
::turso_ext::ResultCode::OK
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user