Skip to main content

harmos_domain/operations/storage/
finish_file.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16// Standard Library Imports
17
18// Third Party Imports
19
20// Local Imports
21use super::POLICY;
22use crate::MemorySize;
23use crate::model::storage::codec::{Nested, product};
24use crate::model::storage::{FileReference, FileSession, MutationId};
25use crate::operations::{ReplaySafety, Visibility};
26
27/* === Constants === */
28
29/* === Macros === */
30
31product!(FinishFile {
32    mutation: Nested<MutationId> => 1,
33    session: Nested<FileSession> => 2,
34});
35
36crate::declare!(FinishFile {
37    id: "storage.finish_file",
38    version: 1,
39    policy: POLICY,
40    response: FileReference,
41    visibility: Visibility::Host,
42    replay: ReplaySafety::Idempotent,
43});
44
45/* === Type Aliases === */
46
47/* === Structs === */
48
49// Finish A Producing File Session Into An Immutable Reference.
50#[derive(Clone, Debug, PartialEq, Eq)]
51pub struct FinishFile {
52    pub mutation: MutationId,
53    pub session: FileSession,
54}
55
56/* === Enums === */
57
58/* === Traits === */
59
60/* === Implementations === */
61
62impl MemorySize for FinishFile {
63    fn memory_size(&self) -> usize {
64        std::mem::size_of::<Self>()
65            .saturating_add(self.mutation.memory_size().saturating_sub(std::mem::size_of_val(&self.mutation)))
66            .saturating_add(self.session.memory_size().saturating_sub(std::mem::size_of_val(&self.session)))
67    }
68}
69
70/* === Public Functions === */
71
72/* === Private Functions === */
73
74/* === Tests === */