pub struct ExtensionRegistry { /* private fields */ }Expand description
The providers this module was built with, and the sources a page opened.
Failures are thrown as plain string messages, not Error objects.
Implementations§
Source§impl ExtensionRegistry
impl ExtensionRegistry
Sourcepub fn supports(&self, provider: &str) -> bool
pub fn supports(&self, provider: &str) -> bool
Whether this module opens a project’s provider source (JSON).
Sourcepub fn probe(&self, bytes: &[u8]) -> Result<Option<String>, JsValue>
pub fn probe(&self, bytes: &[u8]) -> Result<Option<String>, JsValue>
What the first provider that claims bytes finds, as JSON
{ provider, report }, or undefined when none does.
§Errors
Why bytes a provider claims cannot be read.
Sourcepub fn register_resource(&mut self, locator: String, bytes: Vec<u8>)
pub fn register_resource(&mut self, locator: String, bytes: Vec<u8>)
Registers bytes under a locator: an image sequence’s frame, or an
image an SVG names. A source reads them when it opens or renders, so
a page may register them only for that call (see Self::needs).
Sourcepub fn release_resource(&mut self, locator: &str)
pub fn release_resource(&mut self, locator: &str)
Forgets the bytes registered under a locator.
Sourcepub fn resource_bytes(&self) -> usize
pub fn resource_bytes(&self) -> usize
The bytes registered under locators, all together.
Sourcepub fn register_font(&mut self, bytes: Vec<u8>)
pub fn register_font(&mut self, bytes: Vec<u8>)
Registers a font an SVG’s text may draw with, after those registered before. A source reads the fonts when it opens.
Sourcepub fn clear_fonts(&mut self)
pub fn clear_fonts(&mut self)
Forgets every registered font. Sources opened before keep the fonts they opened with.
Sourcepub fn open_needs(&self, provider: &str) -> Result<String, JsValue>
pub fn open_needs(&self, provider: &str) -> Result<String, JsValue>
The resources opening a project’s provider source (JSON) reads, as a JSON array of locators: an image sequence’s first frame.
§Errors
When the provider source is not valid JSON.
Sourcepub fn needs(&self, handle: u32, time_ticks: i64) -> Result<String, JsValue>
pub fn needs(&self, handle: u32, time_ticks: i64) -> Result<String, JsValue>
The resources rendering a source at a source tick reads, as a JSON array of locators: those it does not already hold.
§Errors
When the handle is not open.
Sourcepub fn open(
&mut self,
provider: &str,
bytes: Option<Vec<u8>>,
) -> Result<u32, JsValue>
pub fn open( &mut self, provider: &str, bytes: Option<Vec<u8>>, ) -> Result<u32, JsValue>
Opens a project’s provider source (JSON) with its own bytes (none for an image sequence), returning a handle.
§Errors
Why the source cannot be opened.
Sourcepub fn render(
&mut self,
handle: u32,
time_ticks: i64,
fit_width: u32,
fit_height: u32,
) -> Result<RenderedFrame, JsValue>
pub fn render( &mut self, handle: u32, time_ticks: i64, fit_width: u32, fit_height: u32, ) -> Result<RenderedFrame, JsValue>
The frame a source shows at a source tick, rasterized to fit
fit_width by fit_height when it is a vector source (0 by 0 for its
own size).
§Errors
When the handle is not open or the frame cannot be produced.
Sourcepub fn resident_bytes(&self, handle: u32) -> Result<usize, JsValue>
pub fn resident_bytes(&self, handle: u32) -> Result<usize, JsValue>
The bytes an opened source holds between renders: its decoded frames and images, its last rendered frame, its file’s bytes when it keeps them. A page that bounds what its open sources hold counts this.
§Errors
When the handle is not open.
Sourcepub fn reader(&mut self, handle: u32) -> Result<Option<u32>, JsValue>
pub fn reader(&mut self, handle: u32) -> Result<Option<u32>, JsValue>
Another reader of an opened source, positioned on its own, returning
its handle: it shares what the source decoded when it opened (an
animation’s file, checked frames, and kept frames) with the source
and every other reader made from either, and decodes on its own. The
readers stay valid when the source they were made from is released.
undefined for a source that draws any time as cheaply, which a
page shares instead.
§Errors
When the handle is not open.
Of Self::resident_bytes, what the source shares with the readers
made from it (Self::reader): the same bytes for each, which a page
counts once.
§Errors
When the handle is not open.
Trait Implementations§
Source§impl Default for ExtensionRegistry
impl Default for ExtensionRegistry
Source§impl From<ExtensionRegistry> for JsValue
impl From<ExtensionRegistry> for JsValue
Source§fn from(value: ExtensionRegistry) -> Self
fn from(value: ExtensionRegistry) -> Self
Source§impl FromWasmAbi for ExtensionRegistry
impl FromWasmAbi for ExtensionRegistry
Source§impl IntoWasmAbi for ExtensionRegistry
impl IntoWasmAbi for ExtensionRegistry
Source§impl LongRefFromWasmAbi for ExtensionRegistry
impl LongRefFromWasmAbi for ExtensionRegistry
Source§type Abi = WasmPtr<WasmRefCell<ExtensionRegistry>>
type Abi = WasmPtr<WasmRefCell<ExtensionRegistry>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<ExtensionRegistry>
type Anchor = RcRef<ExtensionRegistry>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl RefFromWasmAbi for ExtensionRegistry
impl RefFromWasmAbi for ExtensionRegistry
Source§type Abi = WasmPtr<WasmRefCell<ExtensionRegistry>>
type Abi = WasmPtr<WasmRefCell<ExtensionRegistry>>
Self are recovered from.Source§type Anchor = RcRef<ExtensionRegistry>
type Anchor = RcRef<ExtensionRegistry>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for ExtensionRegistry
impl RefMutFromWasmAbi for ExtensionRegistry
Source§type Abi = WasmPtr<WasmRefCell<ExtensionRegistry>>
type Abi = WasmPtr<WasmRefCell<ExtensionRegistry>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<ExtensionRegistry>
type Anchor = RcRefMut<ExtensionRegistry>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for ExtensionRegistry
impl SupportsInstanceProperty for ExtensionRegistry
impl SupportsStaticProperty for ExtensionRegistry
Source§impl TryFromJsValue for ExtensionRegistry
impl TryFromJsValue for ExtensionRegistry
Source§impl VectorFromWasmAbi for ExtensionRegistry
impl VectorFromWasmAbi for ExtensionRegistry
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[ExtensionRegistry]>
Source§impl VectorIntoWasmAbi for ExtensionRegistry
impl VectorIntoWasmAbi for ExtensionRegistry
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[ExtensionRegistry]>) -> Self::Abi
Source§impl WasmDescribeVector for ExtensionRegistry
impl WasmDescribeVector for ExtensionRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for ExtensionRegistry
impl !Sync for ExtensionRegistry
impl !UnwindSafe for ExtensionRegistry
impl Freeze for ExtensionRegistry
impl Send for ExtensionRegistry
impl Unpin for ExtensionRegistry
impl UnsafeUnpin for ExtensionRegistry
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.