feat: impl Spawn for Core
so that sub systems are able to spawn tasks
This commit is contained in:
@@ -1 +0,0 @@
|
||||
/data
|
||||
@@ -2,11 +2,24 @@ use ::anyhow::Result;
|
||||
use ::crdt_enc_gpgme::KeyHandler;
|
||||
use ::crdt_enc_sodium::EncHandler;
|
||||
use ::crdt_enc_tokio::Storage;
|
||||
use ::futures::task;
|
||||
use ::uuid::Uuid;
|
||||
|
||||
const CURRENT_DATA_VERSION: Uuid = Uuid::from_u128(0xaadfd5a6_6e19_4b24_a802_4fa27c72f20c);
|
||||
|
||||
const SUPPORTED_DATA_VERSIONS: &[Uuid] = &[CURRENT_DATA_VERSION];
|
||||
#[derive(Debug)]
|
||||
struct TokioSpawn;
|
||||
|
||||
impl crdt_enc::CoreSpawn for TokioSpawn {}
|
||||
|
||||
impl task::Spawn for TokioSpawn {
|
||||
fn spawn_obj(&self, future: task::FutureObj<'static, ()>) -> Result<(), task::SpawnError> {
|
||||
// drop tokios `JoinHandle`
|
||||
tokio::spawn(future);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> Result<()> {
|
||||
@@ -18,6 +31,7 @@ async fn main() -> Result<()> {
|
||||
let cryptor = EncHandler::new();
|
||||
let key_cryptor = KeyHandler::new();
|
||||
let open_options = crdt_enc::OpenOptions {
|
||||
spawn: Box::new(TokioSpawn),
|
||||
storage,
|
||||
cryptor,
|
||||
key_cryptor,
|
||||
|
||||
Reference in New Issue
Block a user