Skip to main content

ProvideParamSpec

Trait ProvideParamSpec 

Source
pub trait ProvideParamSpec {
    // Required method
    fn provide() -> ParamsSpec;
}
Expand description

Provides parameter specification for a parameter type.

Implement this trait for a serializable params struct to describe which fields can be configured in the editor and how they should be validated.

use serde::Deserialize;

/// Not strictly required to implement `ProvideParamSpec` but param type
/// must be deserializable to be usable with any node registration macro.
/// See the plugin chapter in the book for an in-depth explanation:
/// <https://beetry.pages.dev/plugins/plugin.html>.
#[derive(Deserialize)]
struct RetryParams;

impl ProvideParamSpec for RetryParams {
    fn provide() -> ParamsSpec {
        [(
            "retry_limit".into(),
            FieldDefinition {
                type_spec: FieldTypeSpec::U64(FieldMetadata::default()),
                description: Some(
                    "Maximum number of retry attempts".into(),
                ),
            },
        )]
        .into_iter1()
        .collect1()
    }
}

Required Methods§

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§