1
0

write rust shit

This commit is contained in:
2025-10-04 22:21:55 +08:00
parent e06fcdf53b
commit f3c7f0905e
3 changed files with 61 additions and 0 deletions

41
wfassoc/src/components.rs Normal file
View 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(),
}
}
}

View File

@ -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
View 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(),
}
}
}