Trait replit_db::Synchronous
source · pub trait Synchronous {
// Required methods
fn set(
&self,
key: impl AsRef<str>,
value: impl AsRef<str>
) -> Result<(), Error>;
fn get(&self, key: impl AsRef<str>) -> Result<String, Error>;
fn delete(&self, key: impl AsRef<str>) -> Result<(), Error>;
fn list(
&self,
prefix: Option<impl AsRef<str>>
) -> Result<Vec<String>, Error>;
}
Expand description
Synchronous support for Database struct. Use this trait by import it then use it right away!
Required Methods§
sourcefn set(&self, key: impl AsRef<str>, value: impl AsRef<str>) -> Result<(), Error>
fn set(&self, key: impl AsRef<str>, value: impl AsRef<str>) -> Result<(), Error>
Set a variable. key
and value
MUST implement AsRef<str>
. (str
and String
implemented this.).
Possible Exception is ErrorKind::HttpError
for HttpError
sourcefn get(&self, key: impl AsRef<str>) -> Result<String, Error>
fn get(&self, key: impl AsRef<str>) -> Result<String, Error>
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(&self, key: impl AsRef<str>) -> Result<(), Error>
fn delete(&self, key: impl AsRef<str>) -> Result<(), Error>
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(&self, prefix: Option<impl AsRef<str>>) -> Result<Vec<String>, Error>
fn list(&self, prefix: Option<impl AsRef<str>>) -> Result<Vec<String>, Error>
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.