renamer_rs/processor/
inputs.rs1use std::fmt::Debug;
2use std::hash::Hash;
3use std::path::{Path, PathBuf};
4
5#[derive(Debug, Eq, PartialEq, Hash)]
7pub enum InputType {
8 File(FileInput),
10 Text(TextInput),
12}
13
14#[derive(Debug, Eq, PartialEq, Hash)]
16pub struct FileInput {
17 value: PathBuf,
18}
19
20#[derive(Debug, Eq, PartialEq, Hash)]
22pub struct TextInput {
23 value: String,
24}
25
26impl InputType {
27 pub fn new_file<P: AsRef<Path>>(value: P) -> Self {
29 Self::File(FileInput::new(value))
30 }
31
32 pub fn new_text<S: AsRef<str>>(value: S) -> Self {
34 Self::Text(TextInput::new(value))
35 }
36}
37
38impl FileInput {
39 pub fn new<P: AsRef<Path>>(value: P) -> Self {
41 Self {
42 value: value.as_ref().into(),
43 }
44 }
45
46 pub fn value(&self) -> &Path {
48 &self.value
49 }
50}
51
52impl TextInput {
53 pub fn new<S: AsRef<str>>(value: S) -> Self {
55 Self {
56 value: value.as_ref().into(),
57 }
58 }
59
60 pub fn value(&self) -> &str {
62 &self.value
63 }
64}