write rust shit
This commit is contained in:
41
wfassoc/src/components.rs
Normal file
41
wfassoc/src/components.rs
Normal file
@ -0,0 +1,41 @@
|
||||
/// The struct representing an Windows acceptable Prgram ID,
|
||||
/// which looks like `Program.Document.2`
|
||||
pub struct ProgId {
|
||||
inner: String,
|
||||
}
|
||||
|
||||
impl ProgId {
|
||||
pub fn new(prog_id: &str) -> Self {
|
||||
Self {
|
||||
inner: prog_id.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Representing an file extension which must start with dot (`.`)
|
||||
/// and followed by arbitrary characters.
|
||||
pub struct FileExt {
|
||||
inner: String,
|
||||
}
|
||||
|
||||
impl FileExt {
|
||||
pub fn new(file_ext: &str) -> Self {
|
||||
Self {
|
||||
inner: file_ext.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Representing an Windows recognizable icon string with format like:
|
||||
/// `@path_to_file.exe,61`.
|
||||
pub struct WinRc {
|
||||
inner: String,
|
||||
}
|
||||
|
||||
impl WinRc {
|
||||
pub fn new(icon: &str) -> Self {
|
||||
Self {
|
||||
inner: icon.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
compile_error!("Crate wfassoc is only supported on Windows.");
|
||||
|
||||
pub(crate) mod components;
|
||||
pub(crate) mod program;
|
||||
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
|
17
wfassoc/src/program.rs
Normal file
17
wfassoc/src/program.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use super::components::*;
|
||||
|
||||
pub struct Program {
|
||||
name: String,
|
||||
prog_id: ProgId,
|
||||
file_exts: Vec<FileExt>,
|
||||
}
|
||||
|
||||
impl Program {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
name: String::new(),
|
||||
prog_id: ProgId::new(""),
|
||||
file_exts: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user