Skip to main content

linguasteg_core/
pipeline.rs

1use crate::RealizationPlan;
2use crate::{CoreResult, LanguageTag, ModelId, ProviderId, StrategyId};
3
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct EncodeRequest {
6    pub carrier_text: String,
7    pub payload: Vec<u8>,
8    pub options: PipelineOptions,
9}
10
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct EncodeOutput {
13    pub stego_text: String,
14}
15
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub struct DecodeRequest {
18    pub stego_text: String,
19    pub options: PipelineOptions,
20}
21
22#[derive(Debug, Clone, PartialEq, Eq)]
23pub struct DecodeOutput {
24    pub payload: Vec<u8>,
25}
26
27#[derive(Debug, Clone, PartialEq, Eq)]
28pub struct ModelSelection {
29    pub provider: ProviderId,
30    pub model: ModelId,
31}
32
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub struct PipelineOptions {
35    pub language: LanguageTag,
36    pub strategy: StrategyId,
37    pub model_selection: Option<ModelSelection>,
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
41pub enum ModelCapability {
42    TokenLogProbabilities,
43    ConstrainedGeneration,
44    DeterministicSeed,
45    StreamingGeneration,
46}
47
48impl ModelCapability {
49    pub fn as_str(self) -> &'static str {
50        match self {
51            Self::TokenLogProbabilities => "token-log-probabilities",
52            Self::ConstrainedGeneration => "constrained-generation",
53            Self::DeterministicSeed => "deterministic-seed",
54            Self::StreamingGeneration => "streaming-generation",
55        }
56    }
57}
58
59pub trait ModelAdapter: Send + Sync {
60    fn id(&self) -> &str;
61    fn supports(&self, capability: ModelCapability) -> bool;
62}
63
64pub trait Encoder: Send + Sync {
65    fn encode(&self, request: EncodeRequest) -> CoreResult<EncodeOutput>;
66}
67
68pub trait Decoder: Send + Sync {
69    fn decode(&self, request: DecodeRequest) -> CoreResult<DecodeOutput>;
70}
71
72pub trait TextExtractor: Send + Sync {
73    fn extract_plans(&self, stego_text: &str) -> CoreResult<Vec<RealizationPlan>>;
74}