Skip to main content

Encoder

Trait Encoder 

Source
pub trait Encoder {
    // Required methods
    fn id(&self) -> &'static str;
    fn encode(
        &self,
        ir: &CadIr,
        writer: &mut dyn Write,
    ) -> Result<ExportReport, CodecError>;

    // Provided method
    fn encode_with_source_fidelity(
        &self,
        ir: &CadIr,
        source_fidelity: Option<&SourceFidelity>,
        writer: &mut dyn Write,
    ) -> Result<ExportReport, CodecError> { ... }
}
Expand description

A native-format writer.

Required Methods§

Source

fn id(&self) -> &'static str

Stable output format id.

Source

fn encode( &self, ir: &CadIr, writer: &mut dyn Write, ) -> Result<ExportReport, CodecError>

Encode one IR document to the target format.

Provided Methods§

Source

fn encode_with_source_fidelity( &self, ir: &CadIr, source_fidelity: Option<&SourceFidelity>, writer: &mut dyn Write, ) -> Result<ExportReport, CodecError>

Encode with decode-time source fidelity when the caller retained it.

Encoders that do not consume source accounting use the neutral model through Encoder::encode.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§