Skip to main content

Host

Struct Host 

Source
pub struct Host { /* private fields */ }
Expand description

A cheap, cloneable, thread-safe handle to the host.

Implementations§

Source§

impl Host

Source

pub fn from_ffi(ffi: HostBox) -> Self

Wraps the host object passed to the plugin. Used by crate::export_plugin! and crate::testing.

Source

pub fn call_raw(&self, method: &str, args_json: &str) -> HostResult<String>

Invokes a host method with pre-encoded JSON.

Source

pub fn call<A, R>(&self, method: &str, args: &A) -> HostResult<R>

Invokes a host method with typed arguments and result.

Source

pub fn log(&self, level: LogLevel, message: impl Into<String>)

Writes message to eov’s log as it is. Warnings and errors also reach the user: eov shows the same text, unchanged, as a notification.

eov’s log stays in English (it goes into bug reports), so write log messages in English, without isolate. To tell the user about a problem in their language, show the translated text with notify or notify_error and log the English one with info or debug, both written by the same code with i18n::shown_and_english: let (shown, english) = i18n::shown_and_english(|| tr!("{} failed", i18n::isolate(&name))); (i18n::in_english runs any code that makes texts in English). A plugin that hands translated text to warn or error has it shown in the user’s language, and accepts that eov’s log gets that language too.

Source

pub fn debug(&self, message: impl Into<String>)

Source

pub fn info(&self, message: impl Into<String>)

Source

pub fn warn(&self, message: impl Into<String>)

Logs a warning and shows the same text to the user as a warning notification. eov’s log is in English: for a text in the user’s language, see log.

Source

pub fn error(&self, message: impl Into<String>)

Logs an error and shows the same text to the user as an error notification. eov’s log is in English: for a text in the user’s language, see log.

Source

pub fn notify(&self, level: NotifyLevel, message: impl Into<String>)

Shows a toast notification.

Source

pub fn notify_error( &self, message: impl Into<String>, detail: impl Into<String>, )

Shows an error toast with an expandable detail text.

Source

pub fn set_status(&self, text: Option<&str>)

Sets (or with None clears) the plugin’s status-bar text.

Source

pub fn snapshot(&self) -> HostResult<HostSnapshot>

A recent, consistent copy of the host state.

Source

pub fn file_info(&self, file_id: FileId) -> HostResult<FileInfo>

Source

pub fn file_properties(&self, file_id: FileId) -> HostResult<PropertyMap>

Every vendor property of a slide (OpenSlide property map).

Source

pub fn open_file(&self, path: impl Into<String>) -> HostResult<()>

Opens a slide in a new tab.

Source

pub fn read_region(&self, request: RegionRequest) -> HostResult<Image>

Reads slide pixels on the calling thread. For RGB slides they are the slide’s own colours, as scanned: eov’s colour adjustments and its colour management (ICC profile to sRGB, see DisplayAdjustments::color_managed) apply to the display only.

Multichannel slides (see FileInfo::channel_names) come back as RGBA too: their visible channels composited with the user’s current channel display, as the viewer shows them.

Source

pub fn read_associated_image( &self, file_id: FileId, name: &str, ) -> HostResult<Image>

Reads an associated image ("label", "macro", "thumbnail", …).

Source

pub fn roi(&self, file_id: FileId) -> HostResult<Option<Rect>>

The host region of interest of a slide.

Source

pub fn measurements(&self, file_id: FileId) -> HostResult<Vec<MeasurementInfo>>

The host measurements of a slide.

Source

pub fn add_toolbar_button(&self, spec: ToolbarButtonSpec) -> HostResult<()>

Source

pub fn update_toolbar_button(&self, update: ButtonUpdate) -> HostResult<()>

Source

pub fn set_toolbar_button_active( &self, button_id: &str, active: bool, ) -> HostResult<()>

Shorthand for toggling a toolbar button’s pressed state.

Source

pub fn remove_toolbar_button(&self, button_id: &str) -> HostResult<()>

Source

pub fn add_hud_button(&self, spec: HudButtonSpec) -> HostResult<()>

Source

pub fn update_hud_button(&self, update: ButtonUpdate) -> HostResult<()>

Source

pub fn remove_hud_button(&self, button_id: &str) -> HostResult<()>

Source

pub fn set_badge( &self, badge_id: &str, file_id: Option<FileId>, text: Option<&str>, ) -> HostResult<()>

Shows a short notice fixed to the corner of the panes showing file_id (every pane with a slide for None); it does not move with the view. text: None removes it.

Source

pub fn register_batch_command(&self, spec: BatchCommandSpec) -> HostResult<()>

Offers a command for headless batch runs (eov batch run <plugin>:<command> SLIDES --out DIR); slides then arrive as HostEvent::BatchRun. Call it in Plugin::create.

Source

pub fn batch_progress( &self, run_id: &str, fraction: Option<f32>, message: Option<&str>, ) -> HostResult<()>

Reports how far the slide of batch run run_id is.

Source

pub fn finish_batch(&self, result: BatchFinishArgs) -> HostResult<()>

Ends the slide of a batch run: the next slide comes once this is sent.

Source

pub fn register_hotkey(&self, spec: HotkeySpec) -> HostResult<()>

Binds a key of its own (not tied to a button or tool); presses arrive as HostEvent::HotkeyPressed. A key eov uses (its shortcut table, which users can change, and Escape, Enter, Delete, Backspace, Tab and plain arrows) or another plugin’s key is refused with HostEvent::RegistrationRefused; tool and button hotkeys are checked the same way.

Source

pub fn unregister_hotkey(&self, hotkey_id: &str) -> HostResult<()>

Source

pub fn register_tool(&self, spec: ToolSpec) -> HostResult<()>

Source

pub fn unregister_tool(&self, tool_id: &str) -> HostResult<()>

Source

pub fn activate_tool(&self, tool_id: &str) -> HostResult<()>

Source

pub fn deactivate_tools(&self) -> HostResult<()>

Returns to the Navigate tool if one of this plugin’s tools is active.

Source

pub fn create_layer(&self, spec: LayerSpec) -> HostResult<Layer>

Creates (or replaces) an overlay layer.

Source

pub fn layer(&self, layer_id: impl Into<String>) -> Layer

A handle to an existing layer.

Source

pub fn open_surface(&self, spec: SurfaceSpec) -> HostResult<Surface>

Opens a Slint surface (sidebar, window or modal).

Source

pub fn surface(&self, surface_id: impl Into<String>) -> Surface

A handle to a surface opened earlier.

Source

pub fn confirm(&self, args: ConfirmArgs) -> HostResult<String>

Asks a yes/no question; the answer arrives as HostEvent::ConfirmResult with the returned request id.

Source

pub fn open_file_dialog(&self, args: FileDialogArgs) -> HostResult<String>

Shows an open-file dialog; the result arrives as HostEvent::DialogResult with the returned request id.

Source

pub fn save_file_dialog(&self, args: FileDialogArgs) -> HostResult<String>

Shows a save-file dialog; the result arrives as HostEvent::DialogResult with the returned request id.

Source

pub fn fetch_model(&self, args: ModelFetchArgs) -> HostResult<String>

Makes a model available in eov’s model store: answered at once when it is stored already, otherwise downloaded once the user agrees and verified against its SHA-256. The answer arrives as HostEvent::ModelFetched with the returned request id. Hosts without a model store answer HostError::is_unsupported.

Source

pub fn resolve_model(&self, sha256: &str) -> HostResult<Option<ModelRecord>>

The stored model whose main file has this SHA-256, if any.

Source

pub fn models(&self) -> HostResult<Vec<ModelRecord>>

Every model in eov’s model store.

Source

pub fn set_view(&self, args: ViewSetArgs) -> HostResult<()>

Source

pub fn pan(&self, pane: Option<PaneId>, dx: f64, dy: f64) -> HostResult<()>

Pans a pane (default: the focused one) by logical screen pixels.

Source

pub fn zoom(&self, pane: Option<PaneId>, factor: f64) -> HostResult<()>

Zooms a pane by factor (> 1 zooms in) around its centre.

Source

pub fn fit(&self, pane: Option<PaneId>) -> HostResult<()>

Source

pub fn set_view_orientation( &self, pane: Option<PaneId>, rotation_deg: f64, flipped: bool, ) -> HostResult<()>

Turns a pane’s view (default: the focused one) about its centre: rotation_deg clockwise (any angle), then mirrored left to right if flipped. Level-0 coordinates are unaffected.

Source

pub fn display_adjustments( &self, pane: Option<PaneId>, ) -> HostResult<DisplayAdjustments>

How a pane displays its slide (tone adjustments, normalisation), so overlays made from slide pixels can match it.

Source

pub fn frame(&self, pane: Option<PaneId>, rect: Rect) -> HostResult<()>

Frames a level-0 rectangle in a pane.

Source

pub fn cycle_pane(&self, offset: i32) -> HostResult<()>

Source

pub fn cycle_tab(&self, offset: i32) -> HostResult<()>

Source

pub fn series(&self, action: SeriesAction) -> HostResult<()>

Source

pub fn request_render(&self) -> HostResult<()>

Asks the host to redraw every pane (e.g. after a filter’s output changed).

Source

pub fn push_undo( &self, entry_id: impl Into<String>, file_id: Option<FileId>, label: impl Into<String>, ) -> HostResult<()>

Records an undoable change. Ctrl/⌘+Z later sends HostEvent::Undo with entry_id.

Source

pub fn clear_undo(&self, file_id: Option<FileId>) -> HostResult<()>

Forgets the plugin’s history entries (of one file, or all).

Source

pub fn register_filter(&self, spec: FilterSpec) -> HostResult<()>

Source

pub fn set_filter_enabled( &self, filter_id: &str, enabled: bool, ) -> HostResult<()>

Source

pub fn unregister_filter(&self, filter_id: &str) -> HostResult<()>

Source

pub fn setting<T: DeserializeOwned>(&self, key: &str) -> HostResult<Option<T>>

Reads a persisted setting.

Source

pub fn set_setting<T: Serialize + ?Sized>( &self, key: &str, value: &T, ) -> HostResult<()>

Persists a setting.

Source

pub fn remove_setting(&self, key: &str) -> HostResult<()>

Source

pub fn start_job( &self, title: impl Into<String>, cancellable: bool, ) -> HostResult<Job>

Shows a background job with progress in the host UI.

Source

pub fn copy_text(&self, text: impl Into<String>) -> HostResult<()>

Source

pub fn post(&self, token: impl Into<String>) -> HostResult<()>

Asks for HostEvent::Posted with token to be delivered on the UI thread.

Source

pub fn subscribe(&self, events: &[&str]) -> HostResult<()>

Restricts the optional events delivered to this plugin (see crate::protocol::event_names).

Trait Implementations§

Source§

impl Clone for Host

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Forget for Host

§

impl Freeze for Host

§

impl Move for Host

§

impl RefUnwindSafe for Host

§

impl Send for Host

§

impl Sync for Host

§

impl Unpin for Host

§

impl UnsafeUnpin for Host

§

impl UnwindSafe for Host

Blanket Implementations§

Source§

impl<T> AlignerFor<1> for T

Source§

type Aligner = AlignTo1<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<2> for T

Source§

type Aligner = AlignTo2<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<4> for T

Source§

type Aligner = AlignTo4<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<8> for T

Source§

type Aligner = AlignTo8<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<16> for T

Source§

type Aligner = AlignTo16<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<32> for T

Source§

type Aligner = AlignTo32<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<64> for T

Source§

type Aligner = AlignTo64<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<128> for T

Source§

type Aligner = AlignTo128<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<256> for T

Source§

type Aligner = AlignTo256<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<512> for T

Source§

type Aligner = AlignTo512<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<1024> for T

Source§

type Aligner = AlignTo1024<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<2048> for T

Source§

type Aligner = AlignTo2048<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<4096> for T

Source§

type Aligner = AlignTo4096<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<8192> for T

Source§

type Aligner = AlignTo8192<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<16384> for T

Source§

type Aligner = AlignTo16384<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> AlignerFor<32768> for T

Source§

type Aligner = AlignTo32768<T>

The AlignTo* type which aligns Self to ALIGNMENT.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'a, T> RCowCompatibleRef<'a> for T
where T: Clone + 'a,

Source§

type RefC = &'a T

The (preferably) ffi-safe equivalent of &Self.
Source§

type ROwned = T

The owned version of Self::RefC.
Source§

fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC

Converts a reference to an FFI-safe type
Source§

fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T

Converts an FFI-safe type to a reference
Source§

impl<S> ROExtAcc for S

Source§

fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F

Gets a reference to a field, determined by offset. Read more
Source§

fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F

Gets a muatble reference to a field, determined by offset. Read more
Source§

fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F

Gets a const pointer to a field, the field is determined by offset. Read more
Source§

fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F

Gets a mutable pointer to a field, determined by offset. Read more
Source§

impl<S> ROExtOps<Aligned> for S

Source§

fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more
Source§

fn f_swap<F>(&mut self, offset: FieldOffset<S, F, Aligned>, right: &mut S)

Swaps a field (determined by offset) with the same field in right. Read more
Source§

fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> F
where F: Copy,

Gets a copy of a field (determined by offset). The field is determined by offset. Read more
Source§

impl<S> ROExtOps<Unaligned> for S

Source§

fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more
Source§

fn f_swap<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, right: &mut S)

Swaps a field (determined by offset) with the same field in right. Read more
Source§

fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> F
where F: Copy,

Gets a copy of a field (determined by offset). The field is determined by offset. Read more
Source§

impl<T> SelfOps for T
where T: ?Sized,

Source§

fn eq_id(&self, other: &Self) -> bool

Compares the address of self with the address of other. Read more
Source§

fn piped<F, U>(self, f: F) -> U
where F: FnOnce(Self) -> U, Self: Sized,

Emulates the pipeline operator, allowing method syntax in more places. Read more
Source§

fn piped_ref<'a, F, U>(&'a self, f: F) -> U
where F: FnOnce(&'a Self) -> U,

The same as piped except that the function takes &Self Useful for functions that take &Self instead of Self. Read more
Source§

fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U
where F: FnOnce(&'a mut Self) -> U,

The same as piped, except that the function takes &mut Self. Useful for functions that take &mut Self instead of Self.
Source§

fn mutated<F>(self, f: F) -> Self
where F: FnOnce(&mut Self), Self: Sized,

Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
Source§

fn observe<F>(self, f: F) -> Self
where F: FnOnce(&Self), Self: Sized,

Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
Source§

fn into_<T>(self) -> T
where Self: Into<T>,

Performs a conversion with Into. using the turbofish .into_::<_>() syntax. Read more
Source§

fn as_ref_<T>(&self) -> &T
where Self: AsRef<T>, T: ?Sized,

Performs a reference to reference conversion with AsRef, using the turbofish .as_ref_::<_>() syntax. Read more
Source§

fn as_mut_<T>(&mut self) -> &mut T
where Self: AsMut<T>, T: ?Sized,

Performs a mutable reference to mutable reference conversion with AsMut, using the turbofish .as_mut_::<_>() syntax. Read more
Source§

fn drop_(self)
where Self: Sized,

Drops self using method notation. Alternative to std::mem::drop. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<This> TransmuteElement for This
where This: ?Sized,

Source§

unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr
where Self: CanTransmuteElement<T>,

Transmutes the element type of this pointer.. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeIdentity for T
where T: ?Sized,

Source§

type Type = T

This is always Self.
Source§

fn into_type(self) -> Self::Type
where Self: Sized, Self::Type: Sized,

Converts a value back to the original type.
Source§

fn as_type(&self) -> &Self::Type

Converts a reference back to the original type.
Source§

fn as_type_mut(&mut self) -> &mut Self::Type

Converts a mutable reference back to the original type.
Source§

fn into_type_box(self: Box<Self>) -> Box<Self::Type>

Converts a box back to the original type.
Source§

fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type> ⓘ

Converts an Arc back to the original type. Read more
Source§

fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>

Converts an Rc back to the original type. Read more
Source§

fn from_type(this: Self::Type) -> Self
where Self: Sized, Self::Type: Sized,

Converts a value back to the original type.
Source§

fn from_type_ref(this: &Self::Type) -> &Self

Converts a reference back to the original type.
Source§

fn from_type_mut(this: &mut Self::Type) -> &mut Self

Converts a mutable reference back to the original type.
Source§

fn from_type_box(this: Box<Self::Type>) -> Box<Self>

Converts a box back to the original type.
Source§

fn from_type_arc(this: Arc<Self::Type>) -> Arc<Self> ⓘ

Converts an Arc back to the original type.
Source§

fn from_type_rc(this: Rc<Self::Type>) -> Rc<Self>

Converts an Rc back to the original type.