Skip to main content

guth_sync/
lib.rs

1#![forbid(unsafe_code)]
2
3#[cfg(not(unix))]
4compile_error!("guth-sync currently supports Unix systems with OpenSSH and rsync");
5
6pub mod policy;
7pub mod profile;
8pub mod transfer;
9
10use guth_cli::{PluginManifest, MANIFEST_SCHEMA};
11use std::io;
12use std::path::PathBuf;
13use uuid::Uuid;
14
15pub const PLUGIN_ID: Uuid = Uuid::from_u128(0x019f613e14ad7205a36d73f8ac49c24e);
16
17pub fn plugin_manifest(executable: PathBuf) -> io::Result<PluginManifest> {
18    let manifest = PluginManifest {
19        schema: MANIFEST_SCHEMA,
20        id: PLUGIN_ID,
21        name: "Guth Sync".to_string(),
22        version: env!("CARGO_PKG_VERSION").to_string(),
23        executable,
24        description: "SSH-encrypted rsync transfers between matching Guth profiles.".to_string(),
25        capabilities: vec!["sync".to_string(), "sync-read-only".to_string()],
26    };
27    manifest.validate()?;
28    Ok(manifest)
29}
30
31#[cfg(test)]
32mod tests {
33    use super::*;
34    use uuid::Version;
35
36    #[test]
37    fn plugin_identity_is_uuid_v7() {
38        assert_eq!(PLUGIN_ID.get_version(), Some(Version::SortRand));
39        let manifest = plugin_manifest(PathBuf::from("/usr/bin/guth-sync")).unwrap();
40        assert!(manifest.supports("sync"));
41        assert!(manifest.supports("sync-read-only"));
42    }
43}