Skip to content

Commit

Permalink
Add default impl codes to StoreMut trait (gluesql#1435)
Browse files Browse the repository at this point in the history
  • Loading branch information
seonghun-dev committed Oct 29, 2023
1 parent e248963 commit bc71fe9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
24 changes: 0 additions & 24 deletions core/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,6 @@ impl StoreMut for MockStorage {
self.schema_map.insert(table_name, schema);
Ok(())
}

async fn delete_schema(&mut self, _table_name: &str) -> Result<()> {
let msg = "[MockStorage] delete_schema is not supported".to_owned();

Err(Error::StorageMsg(msg))
}

async fn append_data(&mut self, _table_name: &str, _rows: Vec<DataRow>) -> Result<()> {
let msg = "[MockStorage] append_data is not supported".to_owned();

Err(Error::StorageMsg(msg))
}

async fn insert_data(&mut self, _table_name: &str, _rows: Vec<(Key, DataRow)>) -> Result<()> {
let msg = "[MockStorage] insert_data is not supported".to_owned();

Err(Error::StorageMsg(msg))
}

async fn delete_data(&mut self, _table_name: &str, _keys: Vec<Key>) -> Result<()> {
let msg = "[MockStorage] delete_data is not supported".to_owned();

Err(Error::StorageMsg(msg))
}
}

impl AlterTable for MockStorage {}
Expand Down
32 changes: 26 additions & 6 deletions core/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use {
use {
crate::{
data::{Key, Schema},
result::Result,
result::{Error, Result},
},
async_trait::async_trait,
futures::stream::Stream,
Expand All @@ -54,13 +54,33 @@ pub trait Store {
/// you can run `INSERT`, `CREATE TABLE`, `DELETE`, `UPDATE` and `DROP TABLE` queries.
#[async_trait(?Send)]
pub trait StoreMut {
async fn insert_schema(&mut self, schema: &Schema) -> Result<()>;
async fn insert_schema(&mut self, _schema: &Schema) -> Result<()> {
let msg = "[Storage] StoreMut::insert_schema is not supported".to_owned();

async fn delete_schema(&mut self, table_name: &str) -> Result<()>;
Err(Error::StorageMsg(msg))
}

async fn append_data(&mut self, table_name: &str, rows: Vec<DataRow>) -> Result<()>;
async fn delete_schema(&mut self, _table_name: &str) -> Result<()> {
let msg = "[Storage] StoreMut::delete_schema is not supported".to_owned();

async fn insert_data(&mut self, table_name: &str, rows: Vec<(Key, DataRow)>) -> Result<()>;
Err(Error::StorageMsg(msg))
}

async fn delete_data(&mut self, table_name: &str, keys: Vec<Key>) -> Result<()>;
async fn append_data(&mut self, _table_name: &str, _rows: Vec<DataRow>) -> Result<()> {
let msg = "[Storage] StoreMut::append_data is not supported".to_owned();

Err(Error::StorageMsg(msg))
}

async fn insert_data(&mut self, _table_name: &str, _rows: Vec<(Key, DataRow)>) -> Result<()> {
let msg = "[Storage] StoreMut::insert_data is not supported".to_owned();

Err(Error::StorageMsg(msg))
}

async fn delete_data(&mut self, _table_name: &str, _keys: Vec<Key>) -> Result<()> {
let msg = "[Storage] StoreMut::delete_data is not supported".to_owned();

Err(Error::StorageMsg(msg))
}
}

0 comments on commit bc71fe9

Please sign in to comment.