harmos_domain/operations/storage/
follow_file.rs1use super::IO_POLICY;
22use crate::MemorySize;
23use crate::model::storage::codec::{Nested, product};
24use crate::model::storage::files::{FileCompletion, FileEvent, FileSource, FollowStart};
25use crate::operations::Visibility;
26
27product!(FollowFile {
32 source: Nested<FileSource> => 1,
33 start: Nested<FollowStart> => 2,
34});
35
36crate::declare!(FollowFile {
37 id: "storage.follow_file",
38 version: 1,
39 policy: IO_POLICY,
40 response: FileCompletion,
41 output: FileEvent,
42 visibility: Visibility::Shared,
43 grpc: ("harmos.storage.v1", "Storage", "FollowFile"),
44 grant: |request: &FollowFile| request.source.grant_scope().map(|scope| crate::plugin::Grant::of("storage.follow_file", scope)),
45});
46
47#[derive(Clone, Debug, PartialEq, Eq)]
52pub struct FollowFile {
53 pub source: FileSource,
54 pub start: FollowStart,
55}
56
57impl MemorySize for FollowFile {
64 fn memory_size(&self) -> usize {
65 std::mem::size_of::<Self>()
66 .saturating_add(self.source.memory_size().saturating_sub(std::mem::size_of_val(&self.source)))
67 .saturating_add(self.start.memory_size().saturating_sub(std::mem::size_of_val(&self.start)))
68 }
69}
70
71