pub trait KVClient {
// Required methods
fn get_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
);
fn set_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
);
fn add_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
);
fn update_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
);
fn delete_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
);
}
Expand description
Callback trait for KV stores.
Implement this trait and use set_client()
to receive callbacks.
Required Methods§
sourcefn get_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
)
fn get_complete( &self, result: Result<(), ErrorCode>, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, )
This callback is called when the get operation completes.
If there wasn’t enough room to store the entire buffer SIZE
will be
returned in result
and the bytes that did fit will be copied into the
buffer.
§Return Values
result
:Ok(())
on successErr(ErrorCode)
on error. ValidErrorCode
s:SIZE
: The value is longer than the provided buffer. The amount of the value that fits in the buffer is provided.NOSUPPORT
: The key could not be found or the caller does not have permission to read this key. The data in thevalue
buffer is meaningless.FAIL
: An internal error occurred and the operation cannot be completed.
key
: The key buffer.value
: The value buffer.
sourcefn set_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
)
fn set_complete( &self, result: Result<(), ErrorCode>, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, )
This callback is called when the set operation completes.
§Return Values
result
:Ok(())
on success,Err(ErrorCode)
on error. ValidErrorCode
s:NOSUPPORT
: The caller does not have permission to store this key.NOMEM
: The key could not be set because the KV store is full.SIZE
: The key could not be set because the key or value is too many bytes.FAIL
: An internal error occurred and the operation cannot be completed.
key
: The key buffer.value
: The value buffer.
sourcefn add_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
)
fn add_complete( &self, result: Result<(), ErrorCode>, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, )
This callback is called when the add operation completes.
§Return Values
result
:Ok(())
on success,Err(ErrorCode)
on error. ValidErrorCode
s:NOSUPPORT
: The key already exists and cannot be added.NOMEM
: The key could not be added because the KV store is full.SIZE
: The key could not be set because the key or value is too many bytes.FAIL
: An internal error occurred and the operation cannot be completed.
key
: The key buffer.value
: The value buffer.
sourcefn update_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
value: SubSliceMut<'static, u8>,
)
fn update_complete( &self, result: Result<(), ErrorCode>, key: SubSliceMut<'static, u8>, value: SubSliceMut<'static, u8>, )
This callback is called when the update operation completes.
§Return Values
result
:Ok(())
on success,Err(ErrorCode)
on error. ValidErrorCode
s:NOSUPPORT
: The key does not already exist and cannot be modified or the caller does not have permission to modify this key.NOMEM
: The key could not be updated because the KV store is full.SIZE
: The key could not be set because the key or value is too many bytes.FAIL
: An internal error occurred and the operation cannot be completed.
key
: The key buffer.value
: The value buffer.
sourcefn delete_complete(
&self,
result: Result<(), ErrorCode>,
key: SubSliceMut<'static, u8>,
)
fn delete_complete( &self, result: Result<(), ErrorCode>, key: SubSliceMut<'static, u8>, )
This callback is called when the delete operation completes.
§Return Values
result
:Ok(())
on success,Err(ErrorCode)
on error. ValidErrorCode
s:NOSUPPORT
: The key does not exist or the caller does not have permission to delete this key.FAIL
: An internal error occurred and the operation cannot be completed.
key
: The key buffer.