use super::IO_POLICY;
use crate::MemorySize;
use crate::model::storage::codec::{Nested, product};
use crate::model::storage::files::{FileCompletion, FileEvent, FileSource, FollowStart};
use crate::operations::Visibility;
product!(FollowFile {
source: Nested<FileSource> => 1,
start: Nested<FollowStart> => 2,
});
crate::declare!(FollowFile {
id: "storage.follow_file",
version: 1,
policy: IO_POLICY,
response: FileCompletion,
output: FileEvent,
visibility: Visibility::Shared,
grpc: ("harmos.storage.v1", "Storage", "FollowFile"),
grant: |request: &FollowFile| request.source.grant_scope().map(|scope| crate::plugin::Grant::of("storage.follow_file", scope)),
});
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct FollowFile {
pub source: FileSource,
pub start: FollowStart,
}
impl MemorySize for FollowFile {
fn memory_size(&self) -> usize {
std::mem::size_of::<Self>()
.saturating_add(self.source.memory_size().saturating_sub(std::mem::size_of_val(&self.source)))
.saturating_add(self.start.memory_size().saturating_sub(std::mem::size_of_val(&self.start)))
}
}