Skip to main content

concrete_core/specification/engines/
plaintext_discarding_conversion.rs

1use super::engine_error;
2use crate::specification::engines::AbstractEngine;
3use crate::specification::entities::PlaintextEntity;
4
5engine_error! {
6    PlaintextDiscardingConversionError for PlaintextDiscardingConversionEngine @
7}
8
9/// A trait for engines converting (discarding) plaintexts .
10///
11/// # Semantics
12///
13/// This [discarding](super#operation-semantics) operation fills the `output` plaintext with the
14/// conversion of the `input` plaintext to a type with a different representation (for instance from
15/// cpu to gpu memory).
16///
17/// # Formal Definition
18pub trait PlaintextDiscardingConversionEngine<Input, Output>: AbstractEngine
19where
20    Input: PlaintextEntity,
21    Output: PlaintextEntity,
22{
23    /// Converts a plaintext .
24    fn discard_convert_plaintext(
25        &mut self,
26        output: &mut Output,
27        input: &Input,
28    ) -> Result<(), PlaintextDiscardingConversionError<Self::EngineError>>;
29
30    /// Unsafely converts a plaintext .
31    ///
32    /// # Safety
33    /// For the _general_ safety concerns regarding this operation, refer to the different variants
34    /// of [`PlaintextDiscardingConversionError`]. For safety concerns _specific_ to an engine,
35    /// refer to the implementer safety section.
36    unsafe fn discard_convert_plaintext_unchecked(&mut self, output: &mut Output, input: &Input);
37}