concrete_core/specification/engines/
plaintext_decoding.rs

1use super::engine_error;
2use crate::specification::engines::AbstractEngine;
3use crate::specification::entities::{CleartextEntity, EncoderEntity, PlaintextEntity};
4
5engine_error! {
6    PlaintextDecodingError for PlaintextDecodingEngine @
7}
8
9/// A trait for engines decoding plaintexts.
10///
11/// # Semantics
12///
13/// This [pure](super#operation-semantics) operation generates a cleartext containing the decoding
14/// of the `input` plaintext under the `encoder` encoder.
15///
16/// # Formal Definition
17pub trait PlaintextDecodingEngine<Encoder, Plaintext, Cleartext>: AbstractEngine
18where
19    Plaintext: PlaintextEntity,
20    Cleartext: CleartextEntity,
21    Encoder: EncoderEntity,
22{
23    /// Decodes a plaintext.
24    fn decode_plaintext(
25        &mut self,
26        encoder: &Encoder,
27        input: &Plaintext,
28    ) -> Result<Cleartext, PlaintextDecodingError<Self::EngineError>>;
29
30    /// Unsafely decodes a plaintext.
31    ///
32    /// # Safety
33    /// For the _general_ safety concerns regarding this operation, refer to the different variants
34    /// of [`PlaintextDecodingError`]. For safety concerns _specific_ to an engine, refer to the
35    /// implementer safety section.
36    unsafe fn decode_plaintext_unchecked(
37        &mut self,
38        input: &Plaintext,
39        encoder: &Encoder,
40    ) -> Cleartext;
41}