pub struct Host { /* private fields */ }Expand description
A cheap, cloneable, thread-safe handle to the host.
Implementations§
Source§impl Host
impl Host
Sourcepub fn from_ffi(ffi: HostBox) -> Self
pub fn from_ffi(ffi: HostBox) -> Self
Wraps the host object passed to the plugin. Used by
crate::export_plugin! and crate::testing.
Sourcepub fn call_raw(&self, method: &str, args_json: &str) -> HostResult<String>
pub fn call_raw(&self, method: &str, args_json: &str) -> HostResult<String>
Invokes a host method with pre-encoded JSON.
Sourcepub fn call<A, R>(&self, method: &str, args: &A) -> HostResult<R>
pub fn call<A, R>(&self, method: &str, args: &A) -> HostResult<R>
Invokes a host method with typed arguments and result.
Sourcepub fn log(&self, level: LogLevel, message: impl Into<String>)
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.
pub fn debug(&self, message: impl Into<String>)
pub fn info(&self, message: impl Into<String>)
Sourcepub fn warn(&self, message: impl Into<String>)
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.
Sourcepub fn error(&self, message: impl Into<String>)
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.
Sourcepub fn notify(&self, level: NotifyLevel, message: impl Into<String>)
pub fn notify(&self, level: NotifyLevel, message: impl Into<String>)
Shows a toast notification.
Sourcepub fn notify_error(
&self,
message: impl Into<String>,
detail: impl Into<String>,
)
pub fn notify_error( &self, message: impl Into<String>, detail: impl Into<String>, )
Shows an error toast with an expandable detail text.
Sourcepub fn set_status(&self, text: Option<&str>)
pub fn set_status(&self, text: Option<&str>)
Sets (or with None clears) the plugin’s status-bar text.
Sourcepub fn snapshot(&self) -> HostResult<HostSnapshot>
pub fn snapshot(&self) -> HostResult<HostSnapshot>
A recent, consistent copy of the host state.
pub fn file_info(&self, file_id: FileId) -> HostResult<FileInfo>
Sourcepub fn file_properties(&self, file_id: FileId) -> HostResult<PropertyMap>
pub fn file_properties(&self, file_id: FileId) -> HostResult<PropertyMap>
Every vendor property of a slide (OpenSlide property map).
Sourcepub fn read_region(&self, request: RegionRequest) -> HostResult<Image>
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.
Sourcepub fn read_associated_image(
&self,
file_id: FileId,
name: &str,
) -> HostResult<Image>
pub fn read_associated_image( &self, file_id: FileId, name: &str, ) -> HostResult<Image>
Reads an associated image ("label", "macro", "thumbnail", …).
Sourcepub fn roi(&self, file_id: FileId) -> HostResult<Option<Rect>>
pub fn roi(&self, file_id: FileId) -> HostResult<Option<Rect>>
The host region of interest of a slide.
Sourcepub fn measurements(&self, file_id: FileId) -> HostResult<Vec<MeasurementInfo>>
pub fn measurements(&self, file_id: FileId) -> HostResult<Vec<MeasurementInfo>>
The host measurements of a slide.
Shorthand for toggling a toolbar button’s pressed state.
Sourcepub fn set_badge(
&self,
badge_id: &str,
file_id: Option<FileId>,
text: Option<&str>,
) -> HostResult<()>
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.
Sourcepub fn register_batch_command(&self, spec: BatchCommandSpec) -> HostResult<()>
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.
Sourcepub fn batch_progress(
&self,
run_id: &str,
fraction: Option<f32>,
message: Option<&str>,
) -> HostResult<()>
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.
Sourcepub fn finish_batch(&self, result: BatchFinishArgs) -> HostResult<()>
pub fn finish_batch(&self, result: BatchFinishArgs) -> HostResult<()>
Ends the slide of a batch run: the next slide comes once this is sent.
Sourcepub fn register_hotkey(&self, spec: HotkeySpec) -> HostResult<()>
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.
pub fn unregister_hotkey(&self, hotkey_id: &str) -> HostResult<()>
pub fn register_tool(&self, spec: ToolSpec) -> HostResult<()>
pub fn unregister_tool(&self, tool_id: &str) -> HostResult<()>
pub fn activate_tool(&self, tool_id: &str) -> HostResult<()>
Sourcepub fn deactivate_tools(&self) -> HostResult<()>
pub fn deactivate_tools(&self) -> HostResult<()>
Returns to the Navigate tool if one of this plugin’s tools is active.
Sourcepub fn create_layer(&self, spec: LayerSpec) -> HostResult<Layer>
pub fn create_layer(&self, spec: LayerSpec) -> HostResult<Layer>
Creates (or replaces) an overlay layer.
Sourcepub fn open_surface(&self, spec: SurfaceSpec) -> HostResult<Surface>
pub fn open_surface(&self, spec: SurfaceSpec) -> HostResult<Surface>
Opens a Slint surface (sidebar, window or modal).
Sourcepub fn surface(&self, surface_id: impl Into<String>) -> Surface
pub fn surface(&self, surface_id: impl Into<String>) -> Surface
A handle to a surface opened earlier.
Sourcepub fn confirm(&self, args: ConfirmArgs) -> HostResult<String>
pub fn confirm(&self, args: ConfirmArgs) -> HostResult<String>
Asks a yes/no question; the answer arrives as
HostEvent::ConfirmResult with the returned request id.
Sourcepub fn open_file_dialog(&self, args: FileDialogArgs) -> HostResult<String>
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.
Sourcepub fn save_file_dialog(&self, args: FileDialogArgs) -> HostResult<String>
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.
Sourcepub fn fetch_model(&self, args: ModelFetchArgs) -> HostResult<String>
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.
Sourcepub fn resolve_model(&self, sha256: &str) -> HostResult<Option<ModelRecord>>
pub fn resolve_model(&self, sha256: &str) -> HostResult<Option<ModelRecord>>
The stored model whose main file has this SHA-256, if any.
Sourcepub fn models(&self) -> HostResult<Vec<ModelRecord>>
pub fn models(&self) -> HostResult<Vec<ModelRecord>>
Every model in eov’s model store.
pub fn set_view(&self, args: ViewSetArgs) -> HostResult<()>
Sourcepub fn pan(&self, pane: Option<PaneId>, dx: f64, dy: f64) -> HostResult<()>
pub fn pan(&self, pane: Option<PaneId>, dx: f64, dy: f64) -> HostResult<()>
Pans a pane (default: the focused one) by logical screen pixels.
Sourcepub fn zoom(&self, pane: Option<PaneId>, factor: f64) -> HostResult<()>
pub fn zoom(&self, pane: Option<PaneId>, factor: f64) -> HostResult<()>
Zooms a pane by factor (> 1 zooms in) around its centre.
pub fn fit(&self, pane: Option<PaneId>) -> HostResult<()>
Sourcepub fn set_view_orientation(
&self,
pane: Option<PaneId>,
rotation_deg: f64,
flipped: bool,
) -> HostResult<()>
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.
Sourcepub fn display_adjustments(
&self,
pane: Option<PaneId>,
) -> HostResult<DisplayAdjustments>
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.
Sourcepub fn frame(&self, pane: Option<PaneId>, rect: Rect) -> HostResult<()>
pub fn frame(&self, pane: Option<PaneId>, rect: Rect) -> HostResult<()>
Frames a level-0 rectangle in a pane.
pub fn cycle_pane(&self, offset: i32) -> HostResult<()>
pub fn cycle_tab(&self, offset: i32) -> HostResult<()>
pub fn series(&self, action: SeriesAction) -> HostResult<()>
Sourcepub fn request_render(&self) -> HostResult<()>
pub fn request_render(&self) -> HostResult<()>
Asks the host to redraw every pane (e.g. after a filter’s output changed).
Sourcepub fn push_undo(
&self,
entry_id: impl Into<String>,
file_id: Option<FileId>,
label: impl Into<String>,
) -> HostResult<()>
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.
Sourcepub fn clear_undo(&self, file_id: Option<FileId>) -> HostResult<()>
pub fn clear_undo(&self, file_id: Option<FileId>) -> HostResult<()>
Forgets the plugin’s history entries (of one file, or all).
pub fn register_filter(&self, spec: FilterSpec) -> HostResult<()>
pub fn set_filter_enabled( &self, filter_id: &str, enabled: bool, ) -> HostResult<()>
pub fn unregister_filter(&self, filter_id: &str) -> HostResult<()>
Sourcepub fn setting<T: DeserializeOwned>(&self, key: &str) -> HostResult<Option<T>>
pub fn setting<T: DeserializeOwned>(&self, key: &str) -> HostResult<Option<T>>
Reads a persisted setting.
Sourcepub fn set_setting<T: Serialize + ?Sized>(
&self,
key: &str,
value: &T,
) -> HostResult<()>
pub fn set_setting<T: Serialize + ?Sized>( &self, key: &str, value: &T, ) -> HostResult<()>
Persists a setting.
pub fn remove_setting(&self, key: &str) -> HostResult<()>
Sourcepub fn start_job(
&self,
title: impl Into<String>,
cancellable: bool,
) -> HostResult<Job>
pub fn start_job( &self, title: impl Into<String>, cancellable: bool, ) -> HostResult<Job>
Shows a background job with progress in the host UI.
pub fn copy_text(&self, text: impl Into<String>) -> HostResult<()>
Sourcepub fn post(&self, token: impl Into<String>) -> HostResult<()>
pub fn post(&self, token: impl Into<String>) -> HostResult<()>
Asks for HostEvent::Posted with token to be delivered on the UI
thread.
Sourcepub fn subscribe(&self, events: &[&str]) -> HostResult<()>
pub fn subscribe(&self, events: &[&str]) -> HostResult<()>
Restricts the optional events delivered to this plugin (see
crate::protocol::event_names).
Trait Implementations§
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
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
Source§fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
Source§fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
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
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read more