concrete_core/specification/engines/
encoder_creation.rs

1use super::engine_error;
2use crate::prelude::EncoderEntity;
3use crate::specification::engines::AbstractEngine;
4
5engine_error! {
6    EncoderCreationError for EncoderCreationEngine @
7}
8
9/// A trait for engines creating encoders from configurations.
10///
11/// # Semantics
12///
13/// This [pure](super#operation-semantics) operation generates an encoder from the `config`
14/// configuration.
15///
16/// # Formal Definition
17pub trait EncoderCreationEngine<Config, Encoder>: AbstractEngine
18where
19    Encoder: EncoderEntity,
20{
21    /// Creates an encoder from a config.
22    fn create_encoder_from(
23        &mut self,
24        config: &Config,
25    ) -> Result<Encoder, EncoderCreationError<Self::EngineError>>;
26
27    /// Unsafely creates an encoder from a config.
28    ///
29    /// # Safety
30    /// For the _general_ safety concerns regarding this operation, refer to the different variants
31    /// of [`EncoderCreationError`]. For safety concerns _specific_ to an engine, refer to the
32    /// implementer safety section.
33    unsafe fn create_encoder_from_unchecked(&mut self, config: &Config) -> Encoder;
34}