1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use super::DittoAttachment;

#[derive(Debug)]

/// A representation of the events that can occur in relation to an attachment fetch.
///
/// There are three different attachment fetch events: `Completed`, `Progress`, or `Deleted`.
///
/// There will be at most one `completed` or `deleted` event per attachment fetch. There can be many
/// `progress` events delivered for each attachment fetch.
///
/// Updates relating to an attachment fetch are delivered by registering a `DittoAttachmentFetcher`
/// through a call to [`fetch_attachment`](crate::store::collection::Collection::fetch_attachment)
pub enum DittoAttachmentFetchEvent {
    /// An attachment fetch event used when the attachment's download has
    /// completed.
    Completed { attachment: DittoAttachment },
    /// An attachment fetch event used when the attachment's download has
    /// progressed but is not yet complete.
    Progress {
        downloaded_bytes: u64,
        total_bytes: u64,
    },
    /// An attachment fetch event used when the attachment is deleted.
    Deleted,
}