sqlx_sqlite/options/
synchronous.rs1use crate::error::Error;
2use std::str::FromStr;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
8pub enum SqliteSynchronous {
9 Off,
10 Normal,
11 #[default]
12 Full,
13 Extra,
14}
15
16impl SqliteSynchronous {
17 pub(crate) fn as_str(&self) -> &'static str {
18 match self {
19 SqliteSynchronous::Off => "OFF",
20 SqliteSynchronous::Normal => "NORMAL",
21 SqliteSynchronous::Full => "FULL",
22 SqliteSynchronous::Extra => "EXTRA",
23 }
24 }
25}
26
27impl FromStr for SqliteSynchronous {
28 type Err = Error;
29
30 fn from_str(s: &str) -> Result<Self, Error> {
31 Ok(match &*s.to_ascii_lowercase() {
32 "off" => SqliteSynchronous::Off,
33 "normal" => SqliteSynchronous::Normal,
34 "full" => SqliteSynchronous::Full,
35 "extra" => SqliteSynchronous::Extra,
36
37 _ => {
38 return Err(Error::Configuration(
39 format!("unknown value {s:?} for `synchronous`").into(),
40 ));
41 }
42 })
43 }
44}