🚧 Adds rbw item struct

Signed-off-by: Ash Svitan <selfsigned-ash@proton.me>
This commit is contained in:
2026-04-30 15:31:03 +02:00
parent e61ff4b825
commit 0430ff2bd2
3 changed files with 49 additions and 8 deletions
+35
View File
@@ -0,0 +1,35 @@
use crate::sh;
use serde::Deserialize;
use std::io::{Error, ErrorKind};
const EXECUTABLE: &str = "rbw";
#[derive(Deserialize, Debug)]
pub struct Item {
pub id: String,
pub name: String,
pub user: String,
pub uris: Vec<String>,
#[serde(rename = "type")]
pub type_: String,
}
pub fn check_rbw() -> Result<(), Error> {
let which = sh::sh(format!("which {}", EXECUTABLE));
if which.is_empty() {
return Err(Error::new(
ErrorKind::Other,
format!("{} is not installed", EXECUTABLE),
));
}
let unlocked = sh::sh(format!("{} unlocked", EXECUTABLE));
if !unlocked.is_empty() {
return Err(Error::new(
ErrorKind::Other,
format!("{} database not unlocked", EXECUTABLE),
));
}
return Ok(());
}