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