Skip to main content

harmos_domain/operations/storage/
follow_stream.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::STREAM_POLICY;
22use crate::MemorySize;
23use crate::model::storage::codec::{Nested, Optional, product};
24use crate::model::storage::{StorageCursor, StoredRow, StreamSelection};
25use crate::operations::Visibility;
26
27/* === Constants === */
28
29/* === Macros === */
30
31product!(FollowStream {
32    after: Optional<Nested<StorageCursor>> => 1,
33    selection: Nested<StreamSelection> => 2,
34});
35
36crate::declare!(FollowStream {
37    id: "storage.follow_stream",
38    version: 1,
39    policy: STREAM_POLICY,
40    response: StorageCursor,
41    output: StoredRow,
42    visibility: Visibility::Host,
43});
44
45/* === Type Aliases === */
46
47/* === Structs === */
48
49#[derive(Clone, Debug, PartialEq, Eq)]
50pub struct FollowStream {
51    pub after: Option<StorageCursor>,
52    pub selection: StreamSelection,
53}
54
55/* === Enums === */
56
57/* === Traits === */
58
59/* === Implementations === */
60
61impl MemorySize for FollowStream {
62    fn memory_size(&self) -> usize {
63        std::mem::size_of::<Self>()
64            .saturating_add(self.after.memory_size().saturating_sub(std::mem::size_of_val(&self.after)))
65            .saturating_add(self.selection.memory_size().saturating_sub(std::mem::size_of_val(&self.selection)))
66    }
67}
68
69/* === Public Functions === */
70
71/* === Private Functions === */
72
73/* === Tests === */