diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-09-25 00:07:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-24 22:07:22 +0000 |
commit | b2abae477115dc6ca97a767c6800c7c3f1aa0ebb (patch) | |
tree | 30efc8654c21ebeb65cc3e60b14b336506ca42ad /ext/fs/ops.rs | |
parent | 98ef7bd8183f7fa534c3bfea8376d4c452b5d8d7 (diff) |
refactor: rewrite more ops to op2 (#20666)
Diffstat (limited to 'ext/fs/ops.rs')
-rw-r--r-- | ext/fs/ops.rs | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs index 289c3de72..bc09a4a25 100644 --- a/ext/fs/ops.rs +++ b/ext/fs/ops.rs @@ -11,7 +11,6 @@ use std::rc::Rc; use deno_core::error::custom_error; use deno_core::error::type_error; use deno_core::error::AnyError; -use deno_core::op; use deno_core::op2; use deno_core::CancelFuture; use deno_core::CancelHandle; @@ -767,11 +766,11 @@ where Ok(target_string) } -#[op] +#[op2(fast)] pub fn op_fs_truncate_sync<P>( state: &mut OpState, - path: &str, - len: u64, + #[string] path: &str, + #[number] len: u64, ) -> Result<(), AnyError> where P: FsPermissions + 'static, @@ -789,11 +788,11 @@ where Ok(()) } -#[op] +#[op2(async)] pub async fn op_fs_truncate_async<P>( state: Rc<RefCell<OpState>>, - path: String, - len: u64, + #[string] path: String, + #[number] len: u64, ) -> Result<(), AnyError> where P: FsPermissions + 'static, @@ -815,14 +814,14 @@ where Ok(()) } -#[op] +#[op2(fast)] pub fn op_fs_utime_sync<P>( state: &mut OpState, - path: &str, - atime_secs: i64, - atime_nanos: u32, - mtime_secs: i64, - mtime_nanos: u32, + #[string] path: &str, + #[number] atime_secs: i64, + #[smi] atime_nanos: u32, + #[number] mtime_secs: i64, + #[smi] mtime_nanos: u32, ) -> Result<(), AnyError> where P: FsPermissions + 'static, @@ -838,14 +837,14 @@ where Ok(()) } -#[op] +#[op2(async)] pub async fn op_fs_utime_async<P>( state: Rc<RefCell<OpState>>, - path: String, - atime_secs: i64, - atime_nanos: u32, - mtime_secs: i64, - mtime_nanos: u32, + #[string] path: String, + #[number] atime_secs: i64, + #[smi] atime_nanos: u32, + #[number] mtime_secs: i64, + #[smi] mtime_nanos: u32, ) -> Result<(), AnyError> where P: FsPermissions + 'static, @@ -1313,12 +1312,13 @@ fn to_seek_from(offset: i64, whence: i32) -> Result<SeekFrom, AnyError> { Ok(seek_from) } -#[op] +#[op2(fast)] +#[number] pub fn op_fs_seek_sync( state: &mut OpState, - rid: ResourceId, - offset: i64, - whence: i32, + #[smi] rid: ResourceId, + #[number] offset: i64, + #[smi] whence: i32, ) -> Result<u64, AnyError> { let pos = to_seek_from(offset, whence)?; let file = FileResource::get_file(state, rid)?; @@ -1326,12 +1326,13 @@ pub fn op_fs_seek_sync( Ok(cursor) } -#[op] +#[op2(async)] +#[number] pub async fn op_fs_seek_async( state: Rc<RefCell<OpState>>, - rid: ResourceId, - offset: i64, - whence: i32, + #[smi] rid: ResourceId, + #[number] offset: i64, + #[smi] whence: i32, ) -> Result<u64, AnyError> { let pos = to_seek_from(offset, whence)?; let file = FileResource::get_file(&state.borrow(), rid)?; @@ -1449,50 +1450,50 @@ pub async fn op_fs_funlock_async( Ok(()) } -#[op] +#[op2(fast)] pub fn op_fs_ftruncate_sync( state: &mut OpState, - rid: ResourceId, - len: u64, + #[smi] rid: ResourceId, + #[number] len: u64, ) -> Result<(), AnyError> { let file = FileResource::get_file(state, rid)?; file.truncate_sync(len)?; Ok(()) } -#[op] +#[op2(async)] pub async fn op_fs_ftruncate_async( state: Rc<RefCell<OpState>>, - rid: ResourceId, - len: u64, + #[smi] rid: ResourceId, + #[number] len: u64, ) -> Result<(), AnyError> { let file = FileResource::get_file(&state.borrow(), rid)?; file.truncate_async(len).await?; Ok(()) } -#[op] +#[op2(fast)] pub fn op_fs_futime_sync( state: &mut OpState, - rid: ResourceId, - atime_secs: i64, - atime_nanos: u32, - mtime_secs: i64, - mtime_nanos: u32, + #[smi] rid: ResourceId, + #[number] atime_secs: i64, + #[smi] atime_nanos: u32, + #[number] mtime_secs: i64, + #[smi] mtime_nanos: u32, ) -> Result<(), AnyError> { let file = FileResource::get_file(state, rid)?; file.utime_sync(atime_secs, atime_nanos, mtime_secs, mtime_nanos)?; Ok(()) } -#[op] +#[op2(async)] pub async fn op_fs_futime_async( state: Rc<RefCell<OpState>>, - rid: ResourceId, - atime_secs: i64, - atime_nanos: u32, - mtime_secs: i64, - mtime_nanos: u32, + #[smi] rid: ResourceId, + #[number] atime_secs: i64, + #[smi] atime_nanos: u32, + #[number] mtime_secs: i64, + #[smi] mtime_nanos: u32, ) -> Result<(), AnyError> { let file = FileResource::get_file(&state.borrow(), rid)?; file |