DialectRegistration

Trait DialectRegistration 

Source
pub trait DialectRegistration: AsAny + Dialect {
    const NAMESPACE: &'static str;

    // Required methods
    fn init(info: DialectInfo) -> Self;
    fn register_operations(info: &mut DialectInfo);
}
Expand description

A DialectRegistration must be implemented for any implementation of Dialect, to allow the dialect to be registered with a crate::Context and instantiated on demand when building ops in the IR.

This is not part of the Dialect trait itself, as that trait must be object safe, and this trait is not object safe.

Required Associated Constants§

Source

const NAMESPACE: &'static str

The namespace of the dialect to register

A dialect namespace serves both as a way to namespace the operations of that dialect, as well as a way to uniquely name/identify the dialect itself. Thus, no two dialects can have the same namespace at the same time.

Required Methods§

Source

fn init(info: DialectInfo) -> Self

Initialize an instance of this dialect to be stored (uniqued) in the current crate::Context.

A dialect will only ever be initialized once per context. A dialect must use interior mutability to satisfy the requirements of the Dialect trait, and to allow the context to store the returned instance in a reference-counted smart pointer.

Source

fn register_operations(info: &mut DialectInfo)

This is called when registering a dialect, to register operations of the dialect.

This is called before DialectRegistration::init.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§