Trait ArrayKind

Source
pub trait ArrayKind:
    Clone
    + Copy
    + Debug
    + Display
    + Eq
    + PartialEq
    + Default
    + Send
    + Sync
    + 'static {
    const EXTENSION_ID: ExtensionId;
    const TYPE_NAME: TypeName;
    const VALUE_NAME: ValueName;

    // Required methods
    fn extension() -> &'static Arc<Extension>;
    fn type_def() -> &'static TypeDef;

    // Provided methods
    fn instantiate_custom_ty(
        array_def: &TypeDef,
        size: impl Into<TypeArg>,
        element_ty: impl Into<TypeArg>,
    ) -> Result<CustomType, SignatureError> { ... }
    fn instantiate_ty(
        array_def: &TypeDef,
        size: impl Into<TypeArg>,
        element_ty: impl Into<TypeArg>,
    ) -> Result<Type, SignatureError> { ... }
    fn custom_ty(
        size: impl Into<TypeArg>,
        element_ty: impl Into<TypeArg>,
    ) -> CustomType { ... }
    fn ty(size: u64, element_ty: Type) -> Type { ... }
    fn ty_parametric(
        size: impl Into<TypeArg>,
        element_ty: impl Into<TypeArg>,
    ) -> Result<Type, SignatureError> { ... }
    fn build_clone<D: Dataflow>(
        builder: &mut D,
        elem_ty: Type,
        size: u64,
        arr: Wire,
    ) -> Result<(Wire, Wire), BuildError> { ... }
    fn build_discard<D: Dataflow>(
        builder: &mut D,
        elem_ty: Type,
        size: u64,
        arr: Wire,
    ) -> Result<(), BuildError> { ... }
}
Expand description

Trait capturing a concrete array implementation in an extension.

Array operations are generically defined over this trait so the different array extensions can share parts of their implementation. See for example GenericArrayOpDef or GenericArrayValue

Currently the available kinds of array are Array (the default one) and ValueArray.

Required Associated Constants§

Source

const EXTENSION_ID: ExtensionId

Identifier of the extension containing the array.

Source

const TYPE_NAME: TypeName

Name of the array type.

Source

const VALUE_NAME: ValueName

Name of the array value.

Required Methods§

Source

fn extension() -> &'static Arc<Extension>

Returns the extension containing the array.

Source

fn type_def() -> &'static TypeDef

Returns the definition for the array type.

Provided Methods§

Source

fn instantiate_custom_ty( array_def: &TypeDef, size: impl Into<TypeArg>, element_ty: impl Into<TypeArg>, ) -> Result<CustomType, SignatureError>

Instantiates an array CustomType from its definition given a size and element type argument.

Source

fn instantiate_ty( array_def: &TypeDef, size: impl Into<TypeArg>, element_ty: impl Into<TypeArg>, ) -> Result<Type, SignatureError>

Instantiates an array type from its definition given a size and element type argument.

Source

fn custom_ty( size: impl Into<TypeArg>, element_ty: impl Into<TypeArg>, ) -> CustomType

Instantiates an array CustomType given a size and element type argument.

Source

fn ty(size: u64, element_ty: Type) -> Type

Instantiate a new array type given a size argument and element type.

This method is equivalent to ArrayKind::ty_parametric, but uses concrete arguments types to ensure no errors are possible.

Source

fn ty_parametric( size: impl Into<TypeArg>, element_ty: impl Into<TypeArg>, ) -> Result<Type, SignatureError>

Instantiate a new array type given the size and element type parameters.

This is a generic version of ArrayKind::ty.

Source

fn build_clone<D: Dataflow>( builder: &mut D, elem_ty: Type, size: u64, arr: Wire, ) -> Result<(Wire, Wire), BuildError>

Adds a operation to a dataflow graph that clones an array of copyable values.

The default implementation uses the array clone operation.

Source

fn build_discard<D: Dataflow>( builder: &mut D, elem_ty: Type, size: u64, arr: Wire, ) -> Result<(), BuildError>

Adds a operation to a dataflow graph that clones an array of copyable values.

The default implementation uses the array clone operation.

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§

Source§

impl ArrayKind for BorrowArray

Source§

const EXTENSION_ID: ExtensionId = EXTENSION_ID

Source§

const TYPE_NAME: TypeName = BORROW_ARRAY_TYPENAME

Source§

const VALUE_NAME: ValueName = BORROW_ARRAY_VALUENAME

Source§

impl ArrayKind for ValueArray

Source§

const EXTENSION_ID: ExtensionId = EXTENSION_ID

Source§

const TYPE_NAME: TypeName = VALUE_ARRAY_TYPENAME

Source§

const VALUE_NAME: ValueName = VALUE_ARRAY_VALUENAME

Source§

impl ArrayKind for Array

Source§

const EXTENSION_ID: ExtensionId = EXTENSION_ID

Source§

const TYPE_NAME: TypeName = ARRAY_TYPENAME

Source§

const VALUE_NAME: ValueName = ARRAY_VALUENAME