use super::DittoAttachment;

/// 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::Store::fetch_attachment)
#[derive(Debug)]
pub enum DittoAttachmentFetchEvent {
    /// An attachment fetch event used when the attachment's download has
    /// completed.
    Completed {
        /// A handle to the fetched attachment
        attachment: DittoAttachment,
    },
    /// An attachment fetch event used when the attachment's download has
    /// progressed but is not yet complete.
    Progress {
        /// Bytes of the attachment downloaded so far
        downloaded_bytes: u64,
        /// Total number of bytes in the full attachment
        total_bytes: u64,
    },
    /// An attachment fetch event used when the attachment is deleted.
    Deleted,
}
