mirror of
https://github.com/msfjarvis/clipboard-substitutor
synced 2025-08-15 00:47:01 +05:30
config: sort
This commit is contained in:
parent
3fadd9467b
commit
3599fccf4e
1 changed files with 18 additions and 18 deletions
|
@ -17,14 +17,6 @@ pub struct Substitutor {
|
||||||
pub action: Action,
|
pub action: Action,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Match {
|
|
||||||
fn check_match(self, string: &str) -> bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Act {
|
|
||||||
fn apply_action(self, input: String) -> String;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
pub enum Matcher {
|
pub enum Matcher {
|
||||||
#[serde(rename = "starts_with")]
|
#[serde(rename = "starts_with")]
|
||||||
|
@ -37,6 +29,24 @@ pub enum Matcher {
|
||||||
Regex { pattern: String },
|
Regex { pattern: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
|
pub enum Action {
|
||||||
|
#[serde(rename = "replace")]
|
||||||
|
Replace { from: String, to: String },
|
||||||
|
#[serde(rename = "prefix")]
|
||||||
|
Prefix { prefix: String },
|
||||||
|
#[serde(rename = "suffix")]
|
||||||
|
Suffix { suffix: String },
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Match {
|
||||||
|
fn check_match(self, string: &str) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Act {
|
||||||
|
fn apply_action(self, input: String) -> String;
|
||||||
|
}
|
||||||
|
|
||||||
impl Match for Matcher {
|
impl Match for Matcher {
|
||||||
fn check_match(self, string: &str) -> bool {
|
fn check_match(self, string: &str) -> bool {
|
||||||
match self {
|
match self {
|
||||||
|
@ -51,16 +61,6 @@ impl Match for Matcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
|
||||||
pub enum Action {
|
|
||||||
#[serde(rename = "replace")]
|
|
||||||
Replace { from: String, to: String },
|
|
||||||
#[serde(rename = "prefix")]
|
|
||||||
Prefix { prefix: String },
|
|
||||||
#[serde(rename = "suffix")]
|
|
||||||
Suffix { suffix: String },
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Act for Action {
|
impl Act for Action {
|
||||||
fn apply_action(self, input: String) -> String {
|
fn apply_action(self, input: String) -> String {
|
||||||
return match self {
|
return match self {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue