1pub mod connection;
2pub mod reply;
3pub mod status;
4pub mod url;
5
6use std::convert::From;
7use std::default::Default;
8
9#[derive(Debug)]
10pub struct Database {
11 pub name: String,
12 pub desc: String,
13}
14
15impl From<String> for Database {
16 fn from(src: String) -> Self {
17 Self {
18 name: src,
19 desc: String::new(),
20 }
21 }
22}
23
24impl Database {
25 pub fn all() -> Self {
26 Database {
27 name: String::from("*"),
28 desc: String::from("All databases"),
29 }
30 }
31
32 pub fn first() -> Self {
33 Database {
34 name: String::from("!"),
35 desc: String::from("All databases (first match)"),
36 }
37 }
38}
39
40impl Default for Database {
41 fn default() -> Self {
42 Self::first()
43 }
44}
45
46#[derive(Debug)]
47pub struct Definition {
48 pub source: Database,
49 pub text: Vec<String>,
50}
51
52impl Definition {
53 pub fn empty() -> Self {
54 Definition {
55 source: Database::all(),
56 text: vec![String::from("No definition")],
57 }
58 }
59}
60
61#[derive(Debug)]
62pub struct Strategy {
63 pub name: String,
64 pub desc: String,
65}
66
67impl From<String> for Strategy {
68 fn from(src: String) -> Self {
69 Strategy {
70 name: src,
71 desc: String::new(),
72 }
73 }
74}
75
76impl Strategy {
77 pub fn exact() -> Self {
78 Self::from(String::from("exact"))
79 }
80
81 pub fn prefix() -> Self {
82 Self::from(String::from("prefix"))
83 }
84}
85
86impl Default for Strategy {
87 fn default() -> Self {
88 Self {
89 name: String::from("."),
90 desc: String::from("Server default"),
91 }
92 }
93}
94
95#[derive(Debug)]
96pub struct Match {
97 pub source: Database,
98 pub word: String,
99}