From 44d7570272aaa561340137fbacd3c01cdba1c58e Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Thu, 17 Jul 2025 23:46:55 -0400 Subject: [PATCH] Add helper/convenience methods for creating io completions --- core/io/mod.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/io/mod.rs b/core/io/mod.rs index 5ba5d2a27..a6ff10a90 100644 --- a/core/io/mod.rs +++ b/core/io/mod.rs @@ -82,6 +82,33 @@ impl Completion { } } + pub fn new_write(complete: F) -> Self + where + F: Fn(i32) + 'static, + { + Self::new(CompletionType::Write(WriteCompletion::new(Box::new( + complete, + )))) + } + + pub fn new_read(buf: Arc>, complete: F) -> Self + where + F: Fn(Arc>, i32) + 'static, + { + Self::new(CompletionType::Read(ReadCompletion::new( + buf, + Box::new(complete), + ))) + } + pub fn new_sync(complete: F) -> Self + where + F: Fn(i32) + 'static, + { + Self::new(CompletionType::Sync(SyncCompletion::new(Box::new( + complete, + )))) + } + pub fn is_completed(&self) -> bool { self.is_completed.get() }