team-ljyzipelo

공개
102줄2.3 KB
1use crate::{gzip, publication, snapshot};
2use std::{ffi::OsStr, path::Path};
3
4#[derive(Clone, Copy, Debug, Default)]
5pub struct Limits {
6 pub snapshot: snapshot::Limits,
7 pub gzip: gzip::Limits,
8 pub publication: publication::Limits,
9}
10
11pub struct Request<'a> {
12 pub input: &'a Path,
13 pub output_parent: &'a Path,
14 pub output_leaf: &'a OsStr,
15 pub limits: Limits,
16}
17
18// 서로 다른 단위와 원래 누적 카운터를 합산하거나 환불하지 않음.
19#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
20pub struct Usage {
21 pub snapshot: snapshot::Usage,
22 pub gzip: gzip::Usage,
23 pub publication: publication::Usage,
24}
25
26#[derive(Clone, Copy, Debug)]
27pub enum Event {
28 Snapshot(snapshot::Checkpoint),
29 Decode(gzip::Checkpoint),
30 Publication(publication::Checkpoint),
31}
32
33#[derive(Clone, Copy, Debug)]
34pub struct Checkpoint {
35 pub event: Event,
36 pub usage: Usage,
37}
38
39#[derive(Debug)]
40pub enum Stop<E> {
41 Cancelled,
42 Callback(E),
43}
44
45#[derive(Clone, Copy, Debug, Eq, PartialEq)]
46pub enum AdapterFailure {
47 MissingSelectedOutput,
48 SelectedLengthMismatch { expected: u64, actual: u64 },
49}
50
51// 원래 오류와 파일 계층의 게시/내구성/close 보고서를 그대로 보존함.
52pub enum Outcome<E> {
53 SnapshotFailed(snapshot::Failure<E>),
54 DecodeFailed(gzip::Error<E>),
55 AdapterFailed(AdapterFailure),
56 Publication(publication::Report<E>),
57}
58
59#[derive(Clone, Copy, Debug)]
60pub struct SnapshotObservation {
61 identity: snapshot::Identity,
62 sha256: [u8; 32],
63}
64
65impl SnapshotObservation {
66 pub(crate) fn from_capture(value: &snapshot::FileSnapshot) -> Self {
67 Self {
68 identity: value.identity(),
69 sha256: value.sha256(),
70 }
71 }
72
73 pub fn identity(&self) -> snapshot::Identity {
74 self.identity
75 }
76
77 pub fn sha256(&self) -> [u8; 32] {
78 self.sha256
79 }
80}
81
82#[derive(Clone, Copy, Debug)]
83pub struct GzipObservation {
84 boundary: gzip::Boundary,
85}
86
87impl GzipObservation {
88 pub(crate) fn from_decode(boundary: gzip::Boundary) -> Self {
89 Self { boundary }
90 }
91
92 pub fn boundary(&self) -> gzip::Boundary {
93 self.boundary
94 }
95}
96
97pub struct Report<E> {
98 pub outcome: Outcome<E>,
99 pub usage: Usage,
100 pub snapshot: Option<SnapshotObservation>,
101 pub decoded: Option<GzipObservation>,
102}