Table of Contents

Interface IAssetRepository

Namespace
Tudormobile.IronLedgerLib
Assembly
Tudormobile.IronLedgerLib.dll

Defines a repository for persisting and retrieving AssetRecord instances along with associated markdown notes.

public interface IAssetRepository

Methods

DeleteAsync(string, CancellationToken)

Deletes the asset record and its associated notes for the given identifier.

Task DeleteAsync(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier to delete.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

ExistsAsync(AssetRecord, CancellationToken)

Determine if a record currently exists in the repository.

Task<bool> ExistsAsync(AssetRecord asset, CancellationToken cancellationToken = default)

Parameters

asset AssetRecord

The asset record to check.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

GetAllAsync(CancellationToken)

Retrieves all stored asset records.

Task<IReadOnlyList<AssetRecord>> GetAllAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<IReadOnlyList<AssetRecord>>

A read-only list of all stored AssetRecord instances.

GetAllIdentifiersAsync(CancellationToken)

Asynchronously retrieves all available asset identifiers.

Task<IReadOnlyList<string>> GetAllIdentifiersAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A cancellation token that can be used to cancel the operation.

Returns

Task<IReadOnlyList<string>>

A read-only list of strings containing all identifiers. The list will be empty if no identifiers are available.

GetAsync(string, CancellationToken)

Retrieves a single asset record by its identifier.

Task<AssetRecord?> GetAsync(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier (see Id).

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<AssetRecord>

The AssetRecord if found; otherwise null.

GetNotesAsync(string, CancellationToken)

Retrieves the markdown notes associated with an asset.

Task<string> GetNotesAsync(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<string>

The markdown text, or Empty if no notes exist.

SaveAsync(AssetRecord, CancellationToken)

Persists an asset record, creating or overwriting any existing record with the same identifier.

Task SaveAsync(AssetRecord asset, CancellationToken cancellationToken = default)

Parameters

asset AssetRecord

The asset record to save.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

SaveNotesAsync(string, string, CancellationToken)

Persists markdown notes for an asset, creating or overwriting any existing notes.

Task SaveNotesAsync(string assetId, string markdown, CancellationToken cancellationToken = default)

Parameters

assetId string

The unique asset identifier.

markdown string

The markdown text to save.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

ValidateId(string?)

Determines whether the specified asset identifier is valid for this repository.

bool ValidateId(string? assetId)

Parameters

assetId string

The asset identifier to validate.

Returns

bool

true if the identifier is acceptable; otherwise, false.

Remarks

The default implementation accepts any well-formed SHA-256 asset identifier (see IsValid(string?)). Override this method in a custom repository to enforce additional constraints, such as limiting identifiers to a known set or applying a different format.