Describes one registered Anki media payload and provides repeatable streaming access to it. More...
Public Member Functions | |
| ValueTask< Stream > | OpenReadAsync (CancellationToken cancellationToken=default) |
| Opens a new readable stream positioned at the beginning of the registered payload. | |
Properties | |
| string | FileName [get] |
| Gets the safe collection-relative filename referenced by note HTML or sound markup. | |
| long | Length [get] |
| Gets the payload size observed during registration. | |
| string | Sha256 [get] |
| Gets the registration-time SHA-256 digest. | |
Describes one registered Anki media payload and provides repeatable streaming access to it.
A descriptor is immutable and does not itself own an open stream, so it does not require disposal. Each OpenReadAsync call creates an independent stream positioned at the beginning; the caller owns and must dispose that returned stream. Cancellation applies while opening, not to later reads from the returned stream.
A descriptor created by AnkiMediaCollection.AddBytes owns an eager defensive copy of the bytes and can be reopened after the caller changes or releases its input buffer. A descriptor created by AnkiMediaCollection.AddFileAsync retains the source path instead. The caller must keep that file readable and unchanged until all package writes are complete.
Length and Sha256 describe registration-time content. Opening a path-backed descriptor does not revalidate those values, but package writing hashes the emitted bytes and rejects a changed source rather than silently producing a package inconsistent with the descriptor.
Definition at line 22 of file AnkiMediaFile.cs.
|
inline |
Opens a new readable stream positioned at the beginning of the registered payload.
| cancellationToken | Cancels the operation before the stream is opened. |
The caller must dispose the returned stream. Multiple streams from the same descriptor have independent positions and may be consumed concurrently. For path-backed media, this accesses the retained source path at call time and therefore may fail if the caller moved, removed, or made the file unreadable after registration.
| OperationCanceledException | cancellationToken is canceled before opening. |
| FileNotFoundException | The path-backed source no longer exists. |
| DirectoryNotFoundException | A path-backed source directory no longer exists. |
| PathTooLongException | The retained source path exceeds a platform path-length limit. |
| UnauthorizedAccessException | The caller cannot read a path-backed source. |
| IOException | The underlying source cannot be opened for reading. |
Definition at line 60 of file AnkiMediaFile.cs.
|
get |
Gets the safe collection-relative filename referenced by note HTML or sound markup.
A portable simple filename without a directory component or path separator.
Definition at line 36 of file AnkiMediaFile.cs.
|
get |
Gets the payload size observed during registration.
The byte length of the registered content, including zero for an empty payload.
Definition at line 40 of file AnkiMediaFile.cs.
|
get |
Gets the registration-time SHA-256 digest.
The 64-character lowercase hexadecimal digest of the registered content.
Definition at line 44 of file AnkiMediaFile.cs.