aeat.domain.attachments._protocols module

Protocol declaration for the attachment store boundary.

Domain-layer protocol that the adapter-layer concrete implementation must satisfy. The concrete implementation is exported as adapters.persistence.storage.AttachmentStore; this module keeps the domain free of adapter imports.

class AttachmentStoreProtocol(*args, **kwargs)[source]

Bases: Protocol

Structural protocol for an attachment storage backend.

The domain service layer (_service.py) accepts any object that satisfies this protocol. The concrete SQL-backed implementation is adapters.persistence.storage.AttachmentStore.

put_bytes(data)[source]

Write data under its SHA-256 digest and return the digest.

Return type:

str

Parameters:

data (bytes)

put_file(source)[source]

Read source into the store and return (sha256, bytes_size).

Return type:

tuple[str, int]

Parameters:

source (Path)

read_bytes(sha256)[source]

Return the raw bytes for sha256.

Return type:

bytes

Parameters:

sha256 (str)

write_manifest(attachment)[source]

Persist attachment as a manifest record.

Return type:

None

Parameters:

attachment (Attachment)

load_manifest(attachment_id)[source]

Load and validate the manifest for attachment_id.

Return type:

Attachment

Returns:

The validated Attachment manifest record.

Parameters:

attachment_id (str)

iter_manifests()[source]

Iterate over every Attachment manifest in sorted attachment-id order.

Return type:

Iterator[Attachment]

verify_blob(attachment_id)[source]

Re-hash the stored blob and verify it matches attachment_id.

Return type:

None

Parameters:

attachment_id (str)