From 68851d6f371ce353d4313a17a4d0461f03061814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 23 Sep 2023 21:33:31 +0200 Subject: refactor: rewrite ops to op2 macro (#20628) Co-authored-by: Matt Mastracci --- ext/fs/ops.rs | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'ext/fs') diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs index 15711e227..289c3de72 100644 --- a/ext/fs/ops.rs +++ b/ext/fs/ops.rs @@ -371,11 +371,11 @@ where Ok(()) } -#[op] +#[op2(fast)] pub fn op_fs_stat_sync

( state: &mut OpState, - path: String, - stat_out_buf: &mut [u32], + #[string] path: String, + #[buffer] stat_out_buf: &mut [u32], ) -> Result<(), AnyError> where P: FsPermissions + 'static, @@ -414,11 +414,11 @@ where Ok(SerializableStat::from(stat)) } -#[op] +#[op2(fast)] pub fn op_fs_lstat_sync

( state: &mut OpState, - path: String, - stat_out_buf: &mut [u32], + #[string] path: String, + #[buffer] stat_out_buf: &mut [u32], ) -> Result<(), AnyError> where P: FsPermissions + 'static, @@ -1123,16 +1123,17 @@ where Ok(()) } -#[op] +#[op2(async)] +#[allow(clippy::too_many_arguments)] pub async fn op_fs_write_file_async

( state: Rc>, - path: String, - mode: Option, + #[string] path: String, + #[smi] mode: Option, append: bool, create: bool, create_new: bool, - data: JsBuffer, - cancel_rid: Option, + #[buffer] data: JsBuffer, + #[smi] cancel_rid: Option, ) -> Result<(), AnyError> where P: FsPermissions + 'static, @@ -1189,11 +1190,12 @@ where Ok(buf.into()) } -#[op] +#[op2(async)] +#[serde] pub async fn op_fs_read_file_async

( state: Rc>, - path: String, - cancel_rid: Option, + #[string] path: String, + #[smi] cancel_rid: Option, ) -> Result where P: FsPermissions + 'static, @@ -1228,10 +1230,11 @@ where Ok(buf.into()) } -#[op] +#[op2] +#[string] pub fn op_fs_read_file_text_sync

( state: &mut OpState, - path: String, + #[string] path: String, ) -> Result where P: FsPermissions + 'static, @@ -1247,11 +1250,12 @@ where Ok(string_from_utf8_lossy(buf)) } -#[op] +#[op2(async)] +#[string] pub async fn op_fs_read_file_text_async

( state: Rc>, - path: String, - cancel_rid: Option, + #[string] path: String, + #[smi] cancel_rid: Option, ) -> Result where P: FsPermissions + 'static, @@ -1375,11 +1379,11 @@ pub async fn op_fs_fsync_async( Ok(()) } -#[op] +#[op2(fast)] pub fn op_fs_fstat_sync( state: &mut OpState, - rid: ResourceId, - stat_out_buf: &mut [u32], + #[smi] rid: ResourceId, + #[buffer] stat_out_buf: &mut [u32], ) -> Result<(), AnyError> { let file = FileResource::get_file(state, rid)?; let stat = file.stat_sync()?; -- cgit v1.2.3