Skip to main content

FileFingerprint

Struct FileFingerprint 

Source
pub struct FileFingerprint {
    pub byte_digest: Option<ByteDigest>,
    pub content_digest: Option<ContentDigest>,
    pub meta_digest: Option<MetaDigest>,
    pub size: u64,
    pub modified_at: Option<DateTime<Utc>>,
}
Expand description

ファイル同一性判定に使用するフィンガープリント。

matches_within_location() が同一location内で 利用可能な最高精度の情報で比較を行う。 cross-location比較には CrossLocationIdentity を使用。

§精度の優先順位(情報量順)

  1. content_digest (Semantic) — フォーマット固有の意味的ハッシュ(ピクセルデータ等)
  2. meta_digest (MetaLevel) — 埋め込みメタデータのハッシュ(PNG tEXt, EXIF等)
  3. byte_digest (ByteLevel) — ファイル全体のバイト列ハッシュ(一致=バイト同一)
  4. size + modified_at (Metadata) — メタデータ比較
  5. size のみ (SizeOnly) — 最低精度

§matches_within_location()の比較信頼性順

  1. byte_digest — バイト完全一致(最も確実、同一アルゴリズムのみ)
  2. content_digest — ピクセル同一性
  3. meta_digest — メタデータ同一性
  4. size + modified_at
  5. size のみ

Fields§

§byte_digest: Option<ByteDigest>

ファイル全体のハッシュ。location固有アルゴリズム(DJB2/SHA-256)。 Cloud Storageではダウンロードなしに取得不可のためNone。

PartialEq未実装 — cross-location比較はコンパイルエラー。

§content_digest: Option<ContentDigest>

フォーマット固有セマンティックハッシュ (PNG IHDR+IDAT 等のピクセルデータ)。 location非依存。PartialEq実装済み。

§meta_digest: Option<MetaDigest>

埋め込みメタデータのハッシュ (PNG tEXt, EXIF等)。 content_digestと合わせて「何が変わったか」を区別する:

  • content_digest一致 + meta_digest不一致 → メタデータだけ変更
  • content_digest不一致 → コンテンツ自体が変更
§size: u64

ファイルサイズ (bytes)。

§modified_at: Option<DateTime<Utc>>

最終更新日時 (ストレージ報告値)。

Implementations§

Source§

impl FileFingerprint

Source

pub fn matches_within_location(&self, other: &FileFingerprint) -> bool

同一location内でのファイル同一性判定。

cross-location比較には使用不可ByteDigest はlocation固有アルゴリズムのため、 異location間で比較するとアルゴリズム不一致エラーになる。 cross-location比較には CrossLocationIdentity を使用。

§画像ファイル = Entity モデル

Content(ピクセルデータ)がEntityのIdentity。メタデータやファイルサイズは 副次的属性であり、メタ変更でsizeが変わっても同一Entityである。 そのため content_digest / meta_digest 比較は size gateより前 に実行し、 hash一致時にsize不一致でも同一と判定する。

§信頼性フォールバック順
  1. 双方に byte_digest → 同一アルゴリズム比較(最も確実)
  2. 双方に content_digest → ピクセル同一性(size無関係で判定)
  3. 双方に meta_digest → メタデータ同一性(size無関係で判定)
  4. size gate → 上記digestが全て比較不可能な場合のみフォールバック
  5. 双方に modified_at → mtime比較(size一致済み)
  6. size一致のみ → 最低精度(false positiveリスクあり)
Source

pub fn precision(&self) -> FingerprintPrecision

このフィンガープリントが保持する最高精度レベル。

content_digest(Semantic)を最上位とする情報量の序列。 matches_within_location() の比較信頼性順(byte_digest最優先)とは独立した軸である。

Source

pub fn effective_precision( &self, other: &FileFingerprint, ) -> FingerprintPrecision

2つのフィンガープリントの比較で使われる実効精度。

双方の精度の低い方が実効精度となる。

Trait Implementations§

Source§

impl Clone for FileFingerprint

Source§

fn clone(&self) -> FileFingerprint

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileFingerprint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FileFingerprint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FileFingerprint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,