1use serde::{Deserialize, Serialize};
2
3use crate::report::CompressionReport;
4
5#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
6#[serde(rename_all = "snake_case")]
7pub enum InputFormat {
8 Auto,
9 OpenAiJson,
10 AnthropicJson,
11 PlainText,
12 CommandOutput,
13 GitDiff,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
17pub struct CompressionInput {
18 pub format: InputFormat,
19 pub bytes: Vec<u8>,
20}
21
22impl CompressionInput {
23 pub fn openai_json(bytes: impl Into<Vec<u8>>) -> Self {
24 Self {
25 format: InputFormat::OpenAiJson,
26 bytes: bytes.into(),
27 }
28 }
29
30 pub fn anthropic_json(bytes: impl Into<Vec<u8>>) -> Self {
31 Self {
32 format: InputFormat::AnthropicJson,
33 bytes: bytes.into(),
34 }
35 }
36
37 pub fn plain_text(bytes: impl Into<Vec<u8>>) -> Self {
38 Self {
39 format: InputFormat::PlainText,
40 bytes: bytes.into(),
41 }
42 }
43
44 pub fn command_output(bytes: impl Into<Vec<u8>>) -> Self {
45 Self {
46 format: InputFormat::CommandOutput,
47 bytes: bytes.into(),
48 }
49 }
50
51 pub fn git_diff(bytes: impl Into<Vec<u8>>) -> Self {
52 Self {
53 format: InputFormat::GitDiff,
54 bytes: bytes.into(),
55 }
56 }
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct CompressionOutput {
61 pub bytes: Vec<u8>,
62 pub report: CompressionReport,
63}