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() }