2025-01-01 04:12:39 +09:00
|
|
|
// Copyright 2018-2025 the Deno authors. MIT license.
|
2023-03-22 12:13:24 +08:00
|
|
|
|
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
use async_trait::async_trait;
|
|
|
|
use deno_core::OpState;
|
2025-01-08 14:52:32 -08:00
|
|
|
use deno_error::JsErrorBox;
|
2023-10-31 12:13:57 +01:00
|
|
|
use denokv_proto::Database;
|
2023-03-22 12:13:24 +08:00
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
|
pub trait DatabaseHandler {
|
|
|
|
type DB: Database + 'static;
|
|
|
|
|
|
|
|
async fn open(
|
|
|
|
&self,
|
|
|
|
state: Rc<RefCell<OpState>>,
|
|
|
|
path: Option<String>,
|
2025-01-08 14:52:32 -08:00
|
|
|
) -> Result<Self::DB, JsErrorBox>;
|
2023-03-22 12:13:24 +08:00
|
|
|
}
|