Skip to main content

harmos_domain/operations/storage/
watch_directory.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// Third Party Imports
18// Local Imports
19use super::IO_POLICY;
20use crate::MemorySize;
21use crate::model::storage::codec::{Flag, Nested, product};
22use crate::model::storage::{DirectoryCompletion, DirectoryEvent, DirectorySelection};
23use crate::operations::{ReplaySafety, Visibility};
24
25/* === Constants === */
26
27/* === Macros === */
28
29product!(WatchDirectory { selection: Nested<DirectorySelection> => 1, include_existing: Flag => 2 });
30crate::declare!(WatchDirectory {
31    id: "storage.watch_directory",
32    version: 1,
33    policy: IO_POLICY,
34    response: DirectoryCompletion,
35    output: DirectoryEvent,
36    visibility: Visibility::Shared,
37    replay: ReplaySafety::Idempotent,
38    grpc: ("harmos.storage.v1", "Storage", "WatchDirectory"),
39});
40
41/* === Type Aliases === */
42
43/* === Structs === */
44
45#[derive(Clone, Debug, PartialEq, Eq)]
46pub struct WatchDirectory {
47    pub selection: DirectorySelection,
48    pub include_existing: bool,
49}
50
51/* === Enums === */
52
53/* === Traits === */
54
55/* === Implementations === */
56
57impl MemorySize for WatchDirectory {
58    fn memory_size(&self) -> usize {
59        std::mem::size_of::<Self>().saturating_add(self.selection.memory_size().saturating_sub(std::mem::size_of_val(&self.selection)))
60    }
61}
62
63/* === Public Functions === */
64
65/* === Private Functions === */
66
67/* === Tests === */