Trait replit_db::Asynchronous
source · pub trait Asynchronous {
// Required methods
fn set<'life0, 'async_trait, T>(
&'life0 self,
key: T,
value: T
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where T: AsRef<str> + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'async_trait, T>(
&'life0 self,
key: T
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where T: AsRef<str> + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'async_trait, T>(
&'life0 self,
key: T
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where T: AsRef<str> + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn list<'life0, 'async_trait, T>(
&'life0 self,
prefix: Option<T>
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>
where T: AsRef<str> + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Asynchronous support for Database struct. Use this trait by import it then use it right away!
Required Methods§
sourcefn set<'life0, 'async_trait, T>(
&'life0 self,
key: T,
value: T
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
fn set<'life0, 'async_trait, T>( &'life0 self, key: T, value: T ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
Set a variable. key
and value
MUST implement AsRef<str>
. (str
and String
implemented this.).
Possible Exception is ErrorKind::HttpError
for HttpError
sourcefn get<'life0, 'async_trait, T>(
&'life0 self,
key: T
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
fn get<'life0, 'async_trait, T>( &'life0 self, key: T ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
Get a variable you just set. key
MUST implement AsRef<str>
. (str
and String
implemented this.).
Possible Exceptions are ErrorKind::HttpError
for HttpError, ErrorKind::NoItemFoundError
for no items were found in the database
sourcefn delete<'life0, 'async_trait, T>(
&'life0 self,
key: T
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
fn delete<'life0, 'async_trait, T>( &'life0 self, key: T ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
Delete a variable you just set. MUST implement AsRef<str>
. (str
and String
implemented this.).
Possible Exceptions are ErrorKind::HttpError
for HttpError, ErrorKind::NoItemFoundError
for no items were found in the database
sourcefn list<'life0, 'async_trait, T>(
&'life0 self,
prefix: Option<T>
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>
fn list<'life0, 'async_trait, T>( &'life0 self, prefix: Option<T> ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>
List variables. Optionally finding variable that contains defined prefix by passing Some
with anything that implements AsRef<str>
. (str
and String
implemented this.) or STRING_NONE
.
Possible Exceptions are ErrorKind::HttpError
for HttpError, ErrorKind::DecodeError
Decoding string error.