1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use std::str::FromStr;
use super::*;
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub enum DatabaseType {
#[default]
Undef,
PostgreSQL,
Oracle,
MySQL,
MongoDB,
MSSQL,
SQLite,
MariaDB,
}
impl FromStr for DatabaseType {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"PostgreSQL" => Ok(Self::PostgreSQL),
_ => Err(format!("'{}' database is not supported!", s)),
}
}
}
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct ProjectBlock {
pub span_range: SpanRange,
pub name: String,
pub database_type: DatabaseType,
pub note: Option<String>,
}
impl From<Span<'_>> for ProjectBlock {
fn from(span: Span<'_>) -> Self {
Self {
span_range: span.start()..span.end(),
..Default::default()
}
}
}