Skip to main content

harmos_domain/operations/storage/
write_objects.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::IO_POLICY;
22use crate::Identifier;
23use crate::MemorySize;
24use crate::model::storage::codec::{Id, Optional, product};
25use crate::model::storage::{DataBatch, WriteCompletion, WriteReceipt};
26use crate::operations::{ReplaySafety, Visibility};
27
28/* === Constants === */
29
30/* === Macros === */
31
32product!(WriteObjects {
33    scope: Optional<Id> => 1,
34});
35
36crate::declare!(WriteObjects {
37    id: "storage.write_objects",
38    version: 1,
39    policy: IO_POLICY,
40    response: WriteCompletion,
41    input: DataBatch,
42    output: WriteReceipt,
43    visibility: Visibility::Shared,
44    replay: ReplaySafety::Unknown,
45    grpc: ("harmos.storage.v1", "Storage", "WriteObjects"),
46});
47
48/* === Type Aliases === */
49
50/* === Structs === */
51
52// Admit Streamed Arrow Batches Of Objects Into One Optional Scope.
53#[derive(Clone, Debug, PartialEq, Eq)]
54pub struct WriteObjects {
55    pub scope: Option<Identifier>,
56}
57
58/* === Enums === */
59
60/* === Traits === */
61
62/* === Implementations === */
63
64impl MemorySize for WriteObjects {
65    fn memory_size(&self) -> usize {
66        std::mem::size_of::<Self>().saturating_add(self.scope.memory_size().saturating_sub(std::mem::size_of_val(&self.scope)))
67    }
68}
69
70/* === Public Functions === */
71
72/* === Private Functions === */
73
74/* === Tests === */