Skip to main content

PartOperation

Trait PartOperation 

Source
pub trait PartOperation: 'static {
    type Args: Serialize + DeserializeOwned + Debug + PartialEq + Clone + 'static;
    type Session: Clone + Default + 'static;

    const KIND: &'static str;
    const INFO: OperationInfo;

    // Required methods
    fn new_args(context: &Context<'_>) -> Self::Args;
    fn run(ctx: &mut StepContext<'_>, args: &Self::Args) -> GeopResult<()>;
    fn form<'a>(
        context: &'a Context<'a>,
        args: &Self::Args,
        editing: &FormState<Self::Session>,
    ) -> EditForm<'a, Self::Args, Self::Session>;

    // Provided methods
    fn begin_event(session: &mut Self::Session) { ... }
    fn canvas(
        context: &Context<'_>,
        edit: Edit<'_, Self::Args, Self::Session>,
        event: &CanvasEvent,
    ) { ... }
}
Expand description

One kind of step of a part, and how it is edited.

Required Associated Constants§

Source

const KIND: &'static str

The name programs store its steps under.

Source

const INFO: OperationInfo

Required Associated Types§

Source

type Args: Serialize + DeserializeOwned + Debug + PartialEq + Clone + 'static

What a step is given. It is saved with the program, so it names targets and elements, never holds their internal ids.

Source

type Session: Clone + Default + 'static

What the editor keeps while a step is edited besides its arguments and the visuals selected: () for most.

Required Methods§

Source

fn new_args(context: &Context<'_>) -> Self::Args

The arguments of a new step: sensible defaults, taking the part it is inserted into into account.

Source

fn run(ctx: &mut StepContext<'_>, args: &Self::Args) -> GeopResult<()>

Declares what the step produces, through ctx (see StepContext::produce).

Source

fn form<'a>( context: &'a Context<'a>, args: &Self::Args, editing: &FormState<Self::Session>, ) -> EditForm<'a, Self::Args, Self::Session>

What the editor shows while the step is edited, with what setting each field does. Never fails: an editor needs the form most exactly when the arguments do not build, so whatever is wrong is said in it.

Provided Methods§

Source

fn begin_event(session: &mut Self::Session)

What the session forgets at the start of every event, before the event is handled: nothing, by default.

Source

fn canvas( context: &Context<'_>, edit: Edit<'_, Self::Args, Self::Session>, event: &CanvasEvent, )

What the pointer or a key did on the canvas: nothing, by default.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§