Skip to content

Commit

Permalink
Have kv-store#open return an optional handle
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottt committed May 22, 2024
1 parent 2bf43ea commit deca629
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions lib/src/component/kv_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ use {

#[async_trait::async_trait]
impl kv_store::Host for Session {
async fn open(&mut self, name: String) -> Result<kv_store::Handle, types::Error> {
async fn open(&mut self, name: String) -> Result<Option<kv_store::Handle>, types::Error> {
if self.object_store.store_exists(&name)? {
let handle = self.obj_store_handle(&name)?;
Ok(handle.into())
Ok(Some(handle.into()))
} else {
Err(
error::Error::ObjectStoreError(ObjectStoreError::UnknownObjectStore(name.clone()))
.into(),
)
Ok(None)
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/wit/deps/fastly/compute.wit
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ interface kv-store {
type pending-insert-handle = u32;
type pending-delete-handle = u32;

open: func(name: string) -> result<handle, error>;
open: func(name: string) -> result<option<handle>, error>;

lookup: func(
store: handle,
Expand Down

0 comments on commit deca629

Please sign in to comment.