pub struct IntegrityChecker {
pub metadata: BackupMetadata,
}Expand description
整合性検証エンジン
バックアップ時のハッシュ計算と保存を担当します。
§使用例
use backup_suite::core::integrity::IntegrityChecker;
use std::path::PathBuf;
let mut checker = IntegrityChecker::new();
// ファイルハッシュ計算と追加
let file = PathBuf::from("test.txt");
let hash = checker.compute_hash(&file).unwrap();
checker.add_file_hash(file, hash);
// メタデータ保存
let backup_dir = PathBuf::from("/backup/backup_20250107_120000");
checker.save_metadata(&backup_dir).unwrap();Fields§
§metadata: BackupMetadataImplementations§
Source§impl IntegrityChecker
impl IntegrityChecker
Sourcepub fn compute_hash(&self, file_path: &Path) -> Result<String>
pub fn compute_hash(&self, file_path: &Path) -> Result<String>
ファイルのSHA-256ハッシュを計算
§引数
file_path- ハッシュ計算対象のファイルパス
§戻り値
成功時は16進数文字列形式のSHA-256ハッシュ、失敗時はエラー
§Errors
以下の場合にエラーを返します:
- ファイルのオープンに失敗した場合
- ファイルの読み込みに失敗した場合
§使用例
use backup_suite::core::integrity::IntegrityChecker;
use std::path::PathBuf;
let checker = IntegrityChecker::new();
let hash = checker.compute_hash(&PathBuf::from("test.txt")).unwrap();
println!("SHA-256: {}", hash);Sourcepub fn add_file_hash(&mut self, relative_path: PathBuf, hash: String)
pub fn add_file_hash(&mut self, relative_path: PathBuf, hash: String)
Sourcepub fn save_metadata(&self, backup_dir: &Path) -> Result<()>
pub fn save_metadata(&self, backup_dir: &Path) -> Result<()>
メタデータをバックアップディレクトリに保存
§引数
backup_dir- バックアップディレクトリのパス
§戻り値
成功時は Ok(())、失敗時はエラー
§Errors
以下の場合にエラーを返します:
- メタデータの保存に失敗した場合
§使用例
use backup_suite::core::integrity::IntegrityChecker;
use std::path::PathBuf;
let mut checker = IntegrityChecker::new();
checker.add_file_hash(PathBuf::from("test.txt"), "abc123...".to_string());
checker.save_metadata(&PathBuf::from("/backup/backup_20250107_120000")).unwrap();Sourcepub fn file_count(&self) -> usize
pub fn file_count(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IntegrityChecker
impl RefUnwindSafe for IntegrityChecker
impl Send for IntegrityChecker
impl Sync for IntegrityChecker
impl Unpin for IntegrityChecker
impl UnwindSafe for IntegrityChecker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.