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
assetIdstringThe unique asset identifier to delete.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
ExistsAsync(AssetRecord, CancellationToken)
Determine if a record currently exists in the repository.
Task<bool> ExistsAsync(AssetRecord asset, CancellationToken cancellationToken = default)
Parameters
assetAssetRecordThe asset record to check.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
GetAllAsync(CancellationToken)
Retrieves all stored asset records.
Task<IReadOnlyList<AssetRecord>> GetAllAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe 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
cancellationTokenCancellationTokenA 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
assetIdstringThe unique asset identifier (see Id).
cancellationTokenCancellationTokenThe 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
assetIdstringThe unique asset identifier.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
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
assetAssetRecordThe asset record to save.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
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
assetIdstringThe unique asset identifier.
markdownstringThe markdown text to save.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
ValidateId(string?)
Determines whether the specified asset identifier is valid for this repository.
bool ValidateId(string? assetId)
Parameters
assetIdstringThe asset identifier to validate.
Returns
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.