refactor: formalize FileStore and IdentitySource ports in notfiles
- Create FileStore trait in crates/notfiles/src/ports.rs capturing all file I/O operations (read, write, rename, remove, metadata, symlink, etc.) - Create FileStoreImpl adapter in crates/notfiles/src/adapters/fs.rs wrapping std::fs - Update linker.rs State::load/save and link_package/unlink_package to accept FileStore parameter for dependency injection - Create IdentitySource port in crates/notsecrets/src/ports.rs - Move IdentitySource trait from sources/mod.rs to ports.rs, maintain backward compatibility via re-export - Update all source implementations to import from ports - Update lib.rs in both crates to re-export ports - Pass FileStoreImpl through call chain in main.rs and lib.rs public API Maintains 100% backward compatible public API; FileStore dependency is internal.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::error::AgeError;
|
||||
use crate::identities::Identity;
|
||||
use crate::identities::x25519::X25519Identity;
|
||||
use crate::sources::IdentitySource;
|
||||
use crate::ports::IdentitySource;
|
||||
use std::io::Write;
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::error::AgeError;
|
||||
use crate::identities::Identity;
|
||||
use crate::identities::encrypted::EncryptedIdentity;
|
||||
use crate::identities::x25519::X25519Identity;
|
||||
use crate::sources::IdentitySource;
|
||||
use crate::ports::IdentitySource;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub struct FileSource {
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
use crate::error::AgeError;
|
||||
use crate::identities::Identity;
|
||||
|
||||
pub mod bitwarden;
|
||||
pub mod file;
|
||||
pub mod prompt;
|
||||
|
||||
pub use crate::ports::IdentitySource;
|
||||
pub use bitwarden::BitwardenSource;
|
||||
pub use file::FileSource;
|
||||
pub use prompt::PromptSource;
|
||||
|
||||
/// Infra boundary trait: an identity resolver that loads key material from an
|
||||
/// external source and returns a concrete Identity.
|
||||
pub trait IdentitySource {
|
||||
fn name(&self) -> &str;
|
||||
fn load(&self) -> Result<Box<dyn Identity>, AgeError>;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::error::AgeError;
|
||||
use crate::identities::Identity;
|
||||
use crate::identities::scrypt::ScryptIdentity;
|
||||
use crate::sources::IdentitySource;
|
||||
use crate::ports::IdentitySource;
|
||||
|
||||
pub struct PromptSource;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user