dittolive_ditto/store/attachment/fetch_event.rs
1use super::DittoAttachment;
2
3/// A representation of the events that can occur in relation to an attachment fetch.
4///
5/// There are three different attachment fetch events: `Completed`, `Progress`, or `Deleted`.
6///
7/// There will be at most one `completed` or `deleted` event per attachment fetch. There can be many
8/// `progress` events delivered for each attachment fetch.
9///
10/// Updates relating to an attachment fetch are delivered by registering a `DittoAttachmentFetcher`
11/// through a call to [`fetch_attachment`](crate::store::Store::fetch_attachment)
12#[derive(Debug)]
13pub enum DittoAttachmentFetchEvent {
14 /// An attachment fetch event used when the attachment's download has
15 /// completed.
16 Completed {
17 /// A handle to the fetched attachment
18 attachment: DittoAttachment,
19 },
20 /// An attachment fetch event used when the attachment's download has
21 /// progressed but is not yet complete.
22 Progress {
23 /// Bytes of the attachment downloaded so far
24 downloaded_bytes: u64,
25 /// Total number of bytes in the full attachment
26 total_bytes: u64,
27 },
28 /// An attachment fetch event used when the attachment is deleted.
29 Deleted,
30}