mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 08:32:23 +03:00
key_value: change to real api
This commit is contained in:
parent
800c4c5bfa
commit
358e2cc447
@ -107,18 +107,17 @@ fn handle_message (
|
||||
}
|
||||
},
|
||||
// kt::KeyValueMessage::Write { ref key, .. } => {
|
||||
kt::KeyValueMessage::Write { ref key, ref val, .. } => {
|
||||
kt::KeyValueMessage::Write { ref key, .. } => {
|
||||
let Some(db) = db else {
|
||||
return Err(anyhow::anyhow!("cannot send New more than once"));
|
||||
};
|
||||
|
||||
// let Payload { mime: _, ref bytes } = get_payload().ok_or(anyhow::anyhow!("couldnt get bytes for Write"))?;
|
||||
let Payload { mime: _, ref bytes } = get_payload().ok_or(anyhow::anyhow!("couldnt get bytes for Write"))?;
|
||||
|
||||
let write_txn = db.begin_write()?;
|
||||
{
|
||||
let mut table = write_txn.open_table(TABLE)?;
|
||||
// table.insert(&key[..], &bytes[..])?;
|
||||
table.insert(&key[..], &val[..])?;
|
||||
table.insert(&key[..], &bytes[..])?;
|
||||
}
|
||||
write_txn.commit()?;
|
||||
|
||||
@ -150,17 +149,15 @@ fn handle_message (
|
||||
);
|
||||
},
|
||||
Some(v) => {
|
||||
print_to_terminal(0, &format!("key_value_worker: key {:?} value {:?}", key, v.value().to_vec()));
|
||||
send_response(
|
||||
&Response {
|
||||
ipc,
|
||||
metadata: None,
|
||||
},
|
||||
None,
|
||||
// Some(&Payload {
|
||||
// mime: None,
|
||||
// bytes: v.value().to_vec(),
|
||||
// }),
|
||||
Some(&Payload {
|
||||
mime: None,
|
||||
bytes: v.value().to_vec(),
|
||||
}),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
@ -313,8 +313,7 @@ impl VfsError {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum KeyValueMessage {
|
||||
New { drive: String },
|
||||
// Write { drive: String, key: Vec<u8> },
|
||||
Write { drive: String, key: Vec<u8>, val: Vec<u8> },
|
||||
Write { drive: String, key: Vec<u8> },
|
||||
Read { drive: String, key: Vec<u8> },
|
||||
}
|
||||
|
||||
|
@ -610,11 +610,9 @@ pub enum KeyValueMessage {
|
||||
New {
|
||||
drive: String,
|
||||
},
|
||||
// Write { drive: String, key: Vec<u8> },
|
||||
Write {
|
||||
drive: String,
|
||||
key: Vec<u8>,
|
||||
val: Vec<u8>,
|
||||
},
|
||||
Read {
|
||||
drive: String,
|
||||
|
Loading…
Reference in New Issue
Block a user