Skip to main content

SlideFfi

Trait SlideFfi 

Source
pub trait SlideFfi: Send + Sync {
    // Required methods
    fn info(&self) -> FfiResult<RString>;
    fn read_region(
        &self,
        region: SlideRegion,
        out: RSliceMut<'_, u8>,
    ) -> FfiResult<()>;
    fn read_associated_image(&self, name: RStr<'_>) -> FfiResult<Pixels>;
    fn call(&self, method: RStr<'_>, args_json: RStr<'_>) -> FfiResult<RString>;
}
Expand description

One open slide.

Send + Sync: render workers read regions concurrently, from several threads at once on the same handle, with none of the host’s locks held. The host drops the handle (from any thread, possibly after the plugin’s shutdown) when the slide is closed everywhere.

Required Methods§

Source

fn info(&self) -> FfiResult<RString>

The slide’s metadata as a JSON crate::protocol::SlideInfo. Called once, right after opening; the host validates it.

Source

fn read_region( &self, region: SlideRegion, out: RSliceMut<'_, u8>, ) -> FfiResult<()>

Writes region into out: region.width·region.height·4 bytes of RGBA with straight alpha, rows top to bottom, no padding. out arrives zeroed, i.e. transparent: pixels without image data may be left alone (the host shows them as the slide’s background).

Source

fn read_associated_image(&self, name: RStr<'_>) -> FfiResult<Pixels>

Decodes the associated image name (one listed in crate::protocol::SlideInfo::associated_images, at the size listed there) as RGBA with straight alpha.

Source

fn call(&self, method: RStr<'_>, args_json: RStr<'_>) -> FfiResult<RString>

A JSON method for slide features added later (the vtable is frozen); unknown methods answer FfiErrorKind::Unsupported.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<'lt, _ErasedPtr> SlideFfi for SlideFfi_TO<'lt, _ErasedPtr>
where Self: Send + Sync, _ErasedPtr: AsPtr<PtrTarget = ()>,