concrete_core/specification/engines/cleartext_discarding_conversion.rs
1use super::engine_error;
2use crate::specification::engines::AbstractEngine;
3use crate::specification::entities::CleartextEntity;
4
5engine_error! {
6 CleartextDiscardingConversionError for CleartextDiscardingConversionEngine @
7}
8
9/// A trait for engines converting (discarding) cleartexts .
10///
11/// # Semantics
12///
13/// This [discarding](super#operation-semantics) operation fills the `output` cleartext with 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 CleartextDiscardingConversionEngine<Input, Output>: AbstractEngine
19where
20 Input: CleartextEntity,
21 Output: CleartextEntity,
22{
23 /// Converts a cleartext .
24 fn discard_convert_cleartext(
25 &mut self,
26 output: &mut Output,
27 input: &Input,
28 ) -> Result<(), CleartextDiscardingConversionError<Self::EngineError>>;
29
30 /// Unsafely converts a cleartext .
31 ///
32 /// # Safety
33 /// For the _general_ safety concerns regarding this operation, refer to the different variants
34 /// of [`CleartextDiscardingConversionError`]. For safety concerns _specific_ to an engine,
35 /// refer to the implementer safety section.
36 unsafe fn discard_convert_cleartext_unchecked(&mut self, output: &mut Output, input: &Input);
37}