Skip to main content

pharos_runtime_media_input/
protocol.rs

1//! Shared wire contract for the media helper and its clients.
2
3use serde::{Deserialize, Serialize};
4
5/// Media extraction modes accepted by the platform media helper.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(rename_all = "snake_case")]
8pub enum MediaExtractMode {
9    AudioTranscript,
10    ImageOcr,
11    ScannedPdfOcr,
12}
13
14/// JSON request accepted by `pharos-media-helper extract`.
15#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16pub struct MediaExtractRequest {
17    pub schema: String,
18    pub mode: MediaExtractMode,
19    pub media_type: String,
20    pub original_name: String,
21    pub input_path: String,
22    #[serde(default)]
23    pub allowed_roots: Vec<String>,
24    #[serde(default)]
25    pub max_input_bytes: u64,
26    #[serde(default)]
27    pub max_output_bytes: usize,
28}
29
30/// JSON response returned by `pharos-media-helper extract`.
31#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
32pub struct MediaExtractResponse {
33    pub schema: String,
34    pub ok: bool,
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    pub text: Option<String>,
37    #[serde(default)]
38    pub diagnostics: Vec<String>,
39    #[serde(default, skip_serializing_if = "Option::is_none")]
40    pub error_code: Option<String>,
41    #[serde(default, skip_serializing_if = "Option::is_none")]
42    pub message: Option<String>,
43    pub retry_safe: bool,
44}