Skip to main content

ClipTarget

Trait ClipTarget 

Source
pub trait ClipTarget {
    // Required methods
    fn accepts(&self, app: &AppHandle) -> Vec<FormatId>;
    fn paste(&self, app: &AppHandle, paste: &Paste<'_>) -> Result<Json, String>;

    // Provided methods
    fn apply(&self, app: &AppHandle, paste: &Paste<'_>) -> Pasted { ... }
    fn context(&self, app: &AppHandle, element: Option<&str>) -> Json { ... }
}
Expand description

Where a paste goes in a component.

Required Methods§

Source

fn accepts(&self, app: &AppHandle) -> Vec<FormatId>

The formats it accepts, richest first.

Source

fn paste(&self, app: &AppHandle, paste: &Paste<'_>) -> Result<Json, String>

Applies a paste, or for a dry run says what it would change: its changes as JSON (a dry run’s are paste special’s preview, a string reading best).

Provided Methods§

Source

fn apply(&self, app: &AppHandle, paste: &Paste<'_>) -> Pasted

Applies a paste (never a dry run: paste special’s previews and an agent’s plan go through ClipTarget::paste). A target whose edit goes through the application’s own loop (a network edit, a viewport command applied next frame) answers Pasted::Later with a result to come (crate::host::pending): its writes still carry paste.group, which stays open until the result arrives, so the paste remains one undo step; the result is published as clipboard.pasted and a failure shown to the user. By default, ClipTarget::paste now.

Source

fn context(&self, app: &AppHandle, element: Option<&str>) -> Json

What a transform may know of the target before adapting a paste to it (Transform::for_target): the image a mask lands on, the range a value is clamped to, the names a pasted one must not take. element is the element pasted into, if any. Nothing by default.

Implementors§