Skip to main content

Operations

Trait Operations 

Source
pub trait Operations:
    Clone
    + Debug
    + PartialEq
    + Serialize
    + DeserializeOwned {
    // Required methods
    fn infos() -> Vec<OperationInfo>;
    fn new_step<S: Scalar>(kind: &str, before: &Part<S>) -> GeopResult<Self>;
    fn apply<S: Scalar>(
        &self,
        part: Part<S>,
        operation_id: &str,
    ) -> GeopResult<Part<S>>;
    fn new_session(&self) -> Box<dyn Any>;
    fn form<'a, S: Scalar>(
        &self,
        before: &'a Part<S>,
        session: &dyn Any,
        selection: &[String],
    ) -> Form<'a, S>;
    fn set<S: Scalar>(
        &mut self,
        before: &Part<S>,
        session: &mut dyn Any,
        selection: &mut Vec<String>,
        key: &str,
        value: Value,
    );
    fn event<S: Scalar>(
        &mut self,
        before: &Part<S>,
        session: &mut dyn Any,
        selection: &mut Vec<String>,
        event: &CanvasEvent<S>,
    );
    fn kind(&self) -> &'static str;
    fn label(&self) -> &'static str;
}
Expand description

A set of operations, each together with its arguments: the enum a crate::Program’s steps hold.

Written by #[derive(Operations)] on an enum whose every variant is Name(NameArgs), with Name the unit struct implementing Operation with Args = NameArgs: it dispatches to Name, and converts from each NameArgs. A variant’s doc comment describes the operation, and #[operation(label = "...")] gives its short name if that is not the variant’s. A step’s session is the session of its operation, boxed: sessions differ by operation.

Required Methods§

Source

fn infos() -> Vec<OperationInfo>

Every operation of the set.

Source

fn new_step<S: Scalar>(kind: &str, before: &Part<S>) -> GeopResult<Self>

A new step of the operation kind, inserted after before, see Operation::new_args.

Source

fn apply<S: Scalar>( &self, part: Part<S>, operation_id: &str, ) -> GeopResult<Part<S>>

Source

fn new_session(&self) -> Box<dyn Any>

A fresh session for editing this step.

Source

fn form<'a, S: Scalar>( &self, before: &'a Part<S>, session: &dyn Any, selection: &[String], ) -> Form<'a, S>

See Operation::form, as an editor reads it; session is one Operations::new_session made for a step of the same operation.

Source

fn set<S: Scalar>( &mut self, before: &Part<S>, session: &mut dyn Any, selection: &mut Vec<String>, key: &str, value: Value, )

Source

fn event<S: Scalar>( &mut self, before: &Part<S>, session: &mut dyn Any, selection: &mut Vec<String>, event: &CanvasEvent<S>, )

Source

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

The operation’s kind, as it is serialized: extrude.

Source

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

The operation’s short name: Extrude.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§