core: Add Completion.complete() helper

This commit is contained in:
Pekka Enberg 2024-01-12 15:51:10 +02:00
parent 2724b0f411
commit 93670b0505
3 changed files with 17 additions and 2 deletions

View file

@ -1,8 +1,21 @@
use cfg_block::cfg_block;
use std::{mem::ManuallyDrop, pin::Pin, sync::Arc};
pub type Complete = dyn Fn(&Buffer) + Send + Sync;
pub struct Completion {
pub buf: Buffer,
pub complete: Box<Complete>,
}
impl Completion {
pub fn new(buf: Buffer, complete: Box<Complete>) -> Self {
Self { buf, complete }
}
pub fn complete(&self) {
(self.complete)(&self.buf);
}
}
pub type BufferData = Pin<Vec<u8>>;