feat: pumpbin born!
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target
|
||||||
4640
Cargo.lock
generated
Normal file
26
Cargo.toml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[package]
|
||||||
|
name = "pumpbin"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
authors = ["b1n <b1n@b1n.io>"]
|
||||||
|
license = "MIT"
|
||||||
|
homepage = "https://b1n.io"
|
||||||
|
repository = "https://github.com/pumpbin/pumpbin"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rfd = { version = "0.14.1", default-features = false , features = ["tokio"]}
|
||||||
|
dirs = "5.0.1"
|
||||||
|
flatbuffers = "24.3.25"
|
||||||
|
open = "5.1.4"
|
||||||
|
bincode = { version = "2.0.0-rc.3", default-features = false , features = ["alloc", "derive", "std"]}
|
||||||
|
anyhow = "1.0.86"
|
||||||
|
rand = "0.8.5"
|
||||||
|
memchr = "2.7.4"
|
||||||
|
aes-gcm = "0.10.3"
|
||||||
|
|
||||||
|
[dependencies.iced]
|
||||||
|
version = "0.13.0-dev"
|
||||||
|
git = "https://github.com/iced-rs/iced"
|
||||||
|
rev = "6c1027af8d54ad21e282337b53097eb196d62c00"
|
||||||
|
default-features = false
|
||||||
|
features = ["advanced", "svg", "tokio", "wgpu"]
|
||||||
BIN
assets/JetBrainsMonoNerdFontPropo-Regular.ttf
Normal file
3
assets/svg/github.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-github" viewBox="0 0 16 16">
|
||||||
|
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 708 B |
4
assets/svg/house-heart-fill.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house-heart-fill" viewBox="0 0 16 16">
|
||||||
|
<path d="M7.293 1.5a1 1 0 0 1 1.414 0L11 3.793V2.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v3.293l2.354 2.353a.5.5 0 0 1-.708.707L8 2.207 1.354 8.853a.5.5 0 1 1-.708-.707z"/>
|
||||||
|
<path d="m14 9.293-6-6-6 6V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5zm-6-.811c1.664-1.673 5.825 1.254 0 5.018-5.825-3.764-1.664-6.691 0-5.018"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 467 B |
1
assets/svg/iconmonstr-line-one-horizontal-lined.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m21 11.75c0-.414-.336-.75-.75-.75h-16.5c-.414 0-.75.336-.75.75s.336.75.75.75h16.5c.414 0 .75-.336.75-.75z" fill-rule="nonzero"/></svg>
|
||||||
|
After Width: | Height: | Size: 289 B |
1
assets/svg/iconmonstr-plus-lined.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m11 11h-7.25c-.414 0-.75.336-.75.75s.336.75.75.75h7.25v7.25c0 .414.336.75.75.75s.75-.336.75-.75v-7.25h7.25c.414 0 .75-.336.75-.75s-.336-.75-.75-.75h-7.25v-7.25c0-.414-.336-.75-.75-.75s-.75.336-.75.75z" fill-rule="nonzero"/></svg>
|
||||||
|
After Width: | Height: | Size: 384 B |
5
assets/svg/magic-star-svgrepo-com.svg
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M17.2903 4.14004L17.2203 7.93004C17.2103 8.45004 17.5403 9.14004 17.9603 9.45004L20.4403 11.33C22.0303 12.53 21.7703 14 19.8703 14.6L16.6403 15.61C16.1003 15.78 15.5303 16.37 15.3903 16.92L14.6203 19.86C14.0103 22.18 12.4903 22.41 11.2303 20.37L9.47027 17.52C9.15027 17 8.39027 16.61 7.79027 16.64L4.45027 16.81C2.06027 16.93 1.38027 15.55 2.94027 13.73L4.92027 11.43C5.29027 11 5.46027 10.2 5.29027 9.66004L4.27027 6.42004C3.68027 4.52004 4.74027 3.47004 6.63027 4.09004L9.58027 5.06004C10.0803 5.22004 10.8303 5.11004 11.2503 4.80004L14.3303 2.58004C16.0003 1.39004 17.3303 2.09004 17.2903 4.14004Z" fill="#292D32"/>
|
||||||
|
<path d="M21.4403 20.4702L18.4103 17.4402C18.1203 17.1502 17.6403 17.1502 17.3503 17.4402C17.0603 17.7302 17.0603 18.2102 17.3503 18.5002L20.3803 21.5302C20.5303 21.6802 20.7203 21.7502 20.9103 21.7502C21.1003 21.7502 21.2903 21.6802 21.4403 21.5302C21.7303 21.2402 21.7303 20.7602 21.4403 20.4702Z" fill="#292D32"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
49
assets/svg/pumpkin-svgrepo-com.svg
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg fill="#000000" height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
viewBox="0 0 496.008 496.008" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path d="M128.084,249.136c0.312,2.168,1.504,4.128,3.304,5.4c1.36,0.96,2.976,1.464,4.616,1.464c0.52,0,1.048-0.056,1.568-0.16
|
||||||
|
l80-16c3.408-0.68,5.976-3.48,6.376-6.928c0.4-3.448-1.48-6.76-4.632-8.192l-88-40c-2.68-1.224-5.784-0.888-8.112,0.88
|
||||||
|
c-2.336,1.752-3.536,4.64-3.128,7.528L128.084,249.136z M190.116,229.024l-47.384,9.48l-4.744-33.168L190.116,229.024z"/>
|
||||||
|
<path d="M278.436,239.84l80,16c0.52,0.104,1.048,0.16,1.568,0.16c1.64,0,3.256-0.504,4.616-1.472
|
||||||
|
c1.8-1.272,2.992-3.224,3.304-5.4l8-56c0.416-2.888-0.792-5.784-3.128-7.528c-2.328-1.768-5.432-2.096-8.112-0.88l-88,40
|
||||||
|
c-3.16,1.44-5.032,4.752-4.632,8.192C272.46,236.368,275.028,239.168,278.436,239.84z M358.02,205.328l-4.744,33.168
|
||||||
|
l-47.384-9.48L358.02,205.328z"/>
|
||||||
|
<path d="M372.036,265.096c-2.88-1.664-6.488-1.4-9.056,0.68c-0.12,0.096-10.048,8.016-26.976,16.568V280c0-4.424-3.576-8-8-8h-32
|
||||||
|
c-4.424,0-8,3.576-8,8v19.56c-5.248,1.152-10.592,2.08-16,2.784V288c0-4.424-3.576-8-8-8h-32c-4.424,0-8,3.576-8,8v14.344
|
||||||
|
c-5.408-0.704-10.752-1.632-16-2.784V280c0-4.424-3.576-8-8-8h-32c-4.424,0-8,3.576-8,8v2.344
|
||||||
|
c-16.928-8.552-26.856-16.48-26.976-16.568c-2.576-2.08-6.168-2.344-9.056-0.68c-2.856,1.672-4.4,4.928-3.856,8.2
|
||||||
|
C120.252,274.168,135.668,360,248.004,360s127.752-85.832,127.888-86.704C376.428,270.024,374.892,266.768,372.036,265.096z
|
||||||
|
M248.004,344c-64.808,0-92.656-30.52-104.264-52.2c5.912,3.344,12.984,6.96,21.088,10.48c2.472,1.064,5.32,0.832,7.568-0.656
|
||||||
|
c2.248-1.48,3.608-4,3.608-6.696V288h16v17.888c0,3.656,2.488,6.848,6.032,7.752c10.752,2.744,21.952,4.616,33.288,5.576
|
||||||
|
c2.24,0.232,4.448-0.56,6.096-2.08c1.648-1.52,2.584-3.64,2.584-5.888V296h16v15.248c0,2.24,0.936,4.376,2.584,5.888
|
||||||
|
c1.648,1.512,3.864,2.288,6.096,2.08c11.336-0.96,22.536-2.832,33.288-5.576c3.544-0.896,6.032-4.096,6.032-7.752V288h16v6.928
|
||||||
|
c0,2.696,1.36,5.208,3.608,6.688c2.256,1.48,5.104,1.712,7.568,0.656c8.096-3.504,15.168-7.136,21.08-10.472
|
||||||
|
C340.652,313.488,312.804,344,248.004,344z"/>
|
||||||
|
<path d="M80.844,231.2l15.92,1.592c0.712-7.008,2.08-14.472,4.232-22.8l-15.504-3.984
|
||||||
|
C83.148,215.136,81.628,223.376,80.844,231.2z"/>
|
||||||
|
<path d="M416.004,416h-96v-16h-0.912c0.192-0.088,0.384-0.192,0.584-0.28c2.76,0.144,5.528,0.28,8.328,0.28
|
||||||
|
c92.632,0,168-75.368,168-168s-75.368-168-168-168c-13.016,0-25.8,1.488-38.256,4.424c3.168-9.552,9.552-13.12,9.832-13.272
|
||||||
|
l4.424-2.208V0h-8c-67.288,0-83.12,47.36-86.848,69.192C195.78,65.784,182.036,64,168.004,64c-92.632,0-168,75.368-168,168
|
||||||
|
s75.368,168,168,168c2.8,0,5.568-0.136,8.336-0.28c0.192,0.096,0.384,0.192,0.584,0.28h-0.92v16h-96c-44.112,0-80,35.888-80,80
|
||||||
|
h16c0-35.288,28.712-64,64-64h98.928c19.2,39.264,65.712,47.544,67.76,47.888l1.312,0.224l1.312-0.216
|
||||||
|
c2.056-0.344,48.56-8.632,67.76-47.888h98.928c35.288,0,64,28.712,64,64h16C496.004,451.888,460.116,416,416.004,416z
|
||||||
|
M288.004,16.272v27.512c-5.344,4.248-13.784,13.448-15.608,29.76c-5.464,1.936-10.84,4.208-16.144,6.736
|
||||||
|
c-0.08,0-0.168-0.008-0.248-0.008V56h-16v24.312c-0.056,0-0.12,0-0.176,0.008c-5.056-2.408-10.168-4.6-15.368-6.472
|
||||||
|
C226.356,58.52,236.268,19.888,288.004,16.272z M304.004,422.408c-13.176,30.632-48.704,39.84-56,41.432
|
||||||
|
c-7.32-1.6-42.824-10.824-56-41.44v-16.208c17.544,6.24,36.344,9.808,56,9.808s38.456-3.568,56-9.8V422.408z M248.004,400
|
||||||
|
c-83.816,0-152-68.184-152-152h-16c0,55.04,26.728,103.832,67.752,134.488C73.5,372.536,16.004,308.928,16.004,232
|
||||||
|
c0-83.816,68.184-152,152-152c13.36,0,26.432,1.784,39.128,5.208C154.62,98.576,110.324,137,90.78,189.2l14.984,5.608
|
||||||
|
C124.996,143.44,170.7,106.76,223.66,98.032c-24.36,17.64-43.448,40.56-54.984,66.744l14.64,6.456
|
||||||
|
c12.632-28.672,35.376-53.112,64.68-69.936c29.304,16.824,52.04,41.264,64.68,69.936l14.64-6.456
|
||||||
|
c-11.544-26.192-30.632-49.128-55.016-66.768c47.6,7.64,88.968,37.416,111.296,81.6l14.28-7.216
|
||||||
|
c-22.424-44.376-62.24-75.56-108.8-87.24c12.64-3.384,25.64-5.152,38.928-5.152c83.816,0,152,68.184,152,152
|
||||||
|
c0,76.928-57.496,140.536-131.752,150.488c41.024-30.656,67.752-79.448,67.752-134.488c0-19.904-3.624-39.688-10.784-58.808
|
||||||
|
l-14.984,5.608c6.48,17.32,9.768,35.216,9.768,53.2C400.004,331.816,331.82,400,248.004,400z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.4 KiB |
8
assets/svg/rust-svgrepo-com.svg
Normal file
|
After Width: | Height: | Size: 12 KiB |
3
assets/svg/three-dots.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-three-dots" viewBox="0 0 16 16">
|
||||||
|
<path d="M3 9.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 272 B |
BIN
logo/pumpbin-1024.png
Normal file
|
After Width: | Height: | Size: 299 KiB |
BIN
logo/pumpbin-256.png
Normal file
|
After Width: | Height: | Size: 53 KiB |
BIN
logo/pumpbin-512.png
Normal file
|
After Width: | Height: | Size: 122 KiB |
22
src/button_style.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
use iced::{
|
||||||
|
widget::button::{Status, Style},
|
||||||
|
Theme,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn selected(theme: &Theme, _: Status) -> Style {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
let mut style = Style::default();
|
||||||
|
style.border.width = 1.0;
|
||||||
|
style.text_color = palette.success.base.color;
|
||||||
|
style.border.color = palette.success.base.color;
|
||||||
|
style
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unselected(theme: &Theme, _: Status) -> Style {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
let mut style = Style::default();
|
||||||
|
style.border.width = 1.0;
|
||||||
|
style.text_color = palette.primary.base.color;
|
||||||
|
style.border.color = palette.primary.base.color;
|
||||||
|
style
|
||||||
|
}
|
||||||
1141
src/lib.rs
Normal file
39
src/main.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
use iced::{
|
||||||
|
advanced::Application,
|
||||||
|
font::{Family, Stretch, Style, Weight},
|
||||||
|
window::{self, Level, Position},
|
||||||
|
Font, Pixels, Settings, Size,
|
||||||
|
};
|
||||||
|
use pumpbin::Pumpbin;
|
||||||
|
|
||||||
|
fn main() -> iced::Result {
|
||||||
|
let size = Size::new(1000.0, 600.0);
|
||||||
|
|
||||||
|
let settings = Settings {
|
||||||
|
id: Some(env!("CARGO_PKG_NAME").into()),
|
||||||
|
window: window::Settings {
|
||||||
|
size,
|
||||||
|
position: Position::Centered,
|
||||||
|
min_size: Some(size),
|
||||||
|
visible: true,
|
||||||
|
resizable: true,
|
||||||
|
decorations: true,
|
||||||
|
transparent: false,
|
||||||
|
level: Level::Normal,
|
||||||
|
exit_on_close_request: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
fonts: vec![include_bytes!("../assets/JetBrainsMonoNerdFontPropo-Regular.ttf").into()],
|
||||||
|
default_font: Font {
|
||||||
|
family: Family::Name("JetBrainsMono Nerd Font"),
|
||||||
|
weight: Weight::Normal,
|
||||||
|
stretch: Stretch::Normal,
|
||||||
|
style: Style::Normal,
|
||||||
|
},
|
||||||
|
default_text_size: Pixels(13.0),
|
||||||
|
antialiasing: true,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
Pumpbin::run(settings)
|
||||||
|
}
|
||||||
207
src/plugin.rs
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
use std::{collections::HashMap, fmt::Display, fs, ops::Not, path::Path};
|
||||||
|
|
||||||
|
use aes_gcm::{aead::Aead, Aes256Gcm, KeyInit, Nonce};
|
||||||
|
use anyhow::anyhow;
|
||||||
|
use bincode::{decode_from_reader, decode_from_slice, encode_to_vec, Decode, Encode};
|
||||||
|
use dirs::data_dir;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
|
||||||
|
pub struct AesGcmPass {
|
||||||
|
key_holder: Vec<u8>,
|
||||||
|
nonce_holder: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AesGcmPass {
|
||||||
|
pub fn key_holder(&self) -> &[u8] {
|
||||||
|
&self.key_holder
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn key_holder_mut(&mut self) -> &mut Vec<u8> {
|
||||||
|
&mut self.key_holder
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn nonce_holder(&self) -> &[u8] {
|
||||||
|
&self.nonce_holder
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn nonce_holder_mut(&mut self) -> &mut Vec<u8> {
|
||||||
|
&mut self.nonce_holder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
|
||||||
|
pub enum EncryptType {
|
||||||
|
None,
|
||||||
|
Xor(Vec<u8>),
|
||||||
|
AesGcm(AesGcmPass),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for EncryptType {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
EncryptType::None => write!(f, "None"),
|
||||||
|
EncryptType::Xor(_) => write!(f, "Xor"),
|
||||||
|
EncryptType::AesGcm(_) => write!(f, "AesGcm"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EncryptType {
|
||||||
|
pub fn encrypt(&self, path: &Path) -> anyhow::Result<Vec<u8>> {
|
||||||
|
let data = fs::read(path)?;
|
||||||
|
|
||||||
|
match self {
|
||||||
|
EncryptType::None => Ok(data),
|
||||||
|
EncryptType::Xor(x) => Ok(data
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(i, byte)| byte ^ x[i % x.len()])
|
||||||
|
.collect()),
|
||||||
|
EncryptType::AesGcm(x) => {
|
||||||
|
let key = aes_gcm::Key::<Aes256Gcm>::from_slice(x.key_holder());
|
||||||
|
let aes = Aes256Gcm::new(key);
|
||||||
|
let nonce = Nonce::from_slice(x.nonce_holder());
|
||||||
|
aes.encrypt(nonce, data.as_slice())
|
||||||
|
.map_err(|e| anyhow!(e.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
|
||||||
|
pub struct Bins {
|
||||||
|
executable: Option<Vec<u8>>,
|
||||||
|
dynamic_library: Option<Vec<u8>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Bins {
|
||||||
|
pub fn executable(&self) -> Option<&Vec<u8>> {
|
||||||
|
self.executable.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dynamic_library(&self) -> Option<&Vec<u8>> {
|
||||||
|
self.dynamic_library.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
|
||||||
|
pub struct Platforms {
|
||||||
|
windows: Option<Bins>,
|
||||||
|
linux: Option<Bins>,
|
||||||
|
darwin: Option<Bins>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Platforms {
|
||||||
|
pub fn windows(&self) -> Option<&Bins> {
|
||||||
|
self.windows.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn linux(&self) -> Option<&Bins> {
|
||||||
|
self.linux.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn darwin(&self) -> Option<&Bins> {
|
||||||
|
self.darwin.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)]
|
||||||
|
pub struct Plugin {
|
||||||
|
plugin_name: String,
|
||||||
|
author: Option<String>,
|
||||||
|
version: Option<String>,
|
||||||
|
desc: Option<String>,
|
||||||
|
prefix: Vec<u8>,
|
||||||
|
size_holder: Option<Vec<u8>>,
|
||||||
|
max_len: usize,
|
||||||
|
encrypt_type: EncryptType,
|
||||||
|
platforms: Platforms,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Plugin {
|
||||||
|
pub fn plugin_name(&self) -> &str {
|
||||||
|
&self.plugin_name
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn author(&self) -> Option<&String> {
|
||||||
|
self.author.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn version(&self) -> Option<&String> {
|
||||||
|
self.version.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn desc(&self) -> Option<&String> {
|
||||||
|
self.desc.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn prefix(&self) -> &[u8] {
|
||||||
|
&self.prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn size_holder(&self) -> Option<&Vec<u8>> {
|
||||||
|
self.size_holder.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn max_len(&self) -> usize {
|
||||||
|
self.max_len
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn encrypt_type(&self) -> &EncryptType {
|
||||||
|
&self.encrypt_type
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn platforms(&self) -> &Platforms {
|
||||||
|
&self.platforms
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Plugin {
|
||||||
|
pub fn reade_plugin(path: &Path) -> anyhow::Result<Plugin> {
|
||||||
|
let config = bincode::config::standard();
|
||||||
|
|
||||||
|
let file = fs::File::open(path)?;
|
||||||
|
let reader = std::io::BufReader::new(file);
|
||||||
|
let decoded_plugin = decode_from_reader(reader, config)?;
|
||||||
|
Ok(decoded_plugin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Default, Encode, Decode, PartialEq, Eq)]
|
||||||
|
pub struct Plugins(pub HashMap<String, Plugin>);
|
||||||
|
|
||||||
|
impl Plugins {
|
||||||
|
pub fn reade_plugins() -> anyhow::Result<Plugins> {
|
||||||
|
let config = bincode::config::standard();
|
||||||
|
|
||||||
|
let mut plugins_path = data_dir().ok_or(anyhow::anyhow!("data_dir is none."))?;
|
||||||
|
plugins_path.push("pumpbin");
|
||||||
|
plugins_path.push("plugins");
|
||||||
|
|
||||||
|
if plugins_path.exists() && plugins_path.is_file() {
|
||||||
|
let plugins = fs::read(plugins_path)?;
|
||||||
|
let (decoded_plugins, _) = decode_from_slice(plugins.as_slice(), config)?;
|
||||||
|
Ok(decoded_plugins)
|
||||||
|
} else {
|
||||||
|
anyhow::bail!("file not exists.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn uptade_plugins(&self) -> anyhow::Result<()> {
|
||||||
|
let config = bincode::config::standard();
|
||||||
|
let buf = encode_to_vec(&self.0, config)?;
|
||||||
|
|
||||||
|
let mut plugins_path = data_dir().ok_or(anyhow::anyhow!("data_dir is none."))?;
|
||||||
|
plugins_path.push("pumpbin");
|
||||||
|
if plugins_path.exists().not() {
|
||||||
|
fs::create_dir_all(&plugins_path)?;
|
||||||
|
} else if plugins_path.exists() && plugins_path.is_dir().not() {
|
||||||
|
fs::remove_file(&plugins_path)?;
|
||||||
|
fs::create_dir_all(&plugins_path)?;
|
||||||
|
}
|
||||||
|
plugins_path.push("plugins");
|
||||||
|
fs::write(plugins_path, buf)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
7
src/svg_style.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
use iced::{widget::svg, Theme};
|
||||||
|
|
||||||
|
pub fn svg_primary_base(theme: &Theme, _: svg::Status) -> svg::Style {
|
||||||
|
svg::Style {
|
||||||
|
color: Some(theme.extended_palette().primary.base.color),
|
||||||
|
}
|
||||||
|
}
|
||||||