pub struct BackendFactory;Expand description
Creates the best rendering backend available on the host.
The preference order is WebGPU, then WebGL2, then Canvas2D. A canvas
can only ever have one kind of context, so the choice has to be made
before the first get_context call — which is why the WebGPU probe
is asynchronous and the factory is asynchronous too.
Implementations§
Source§impl BackendFactory
Inherent implementation of BackendFactory.
impl BackendFactory
Inherent implementation of BackendFactory.
Sourcepub async fn create(
canvas: &HtmlCanvasElement,
preferred: BackendKind,
) -> Option<Box<dyn ChartBackend>>
pub async fn create( canvas: &HtmlCanvasElement, preferred: BackendKind, ) -> Option<Box<dyn ChartBackend>>
Creates the best backend for the given canvas.
preferred is the backend the caller would like; the factory
falls back to the next one down when the host cannot provide it.
The fallback chain is always WebGPU, WebGL2, Canvas2D.
§Arguments
&HtmlCanvasElement- The&HtmlCanvasElementvalue.BackendKind- TheBackendKindvalue.
§Returns
Option<Box<dyn ChartBackend>>- TheOption<Box<dyn ChartBackend>>value.
Sourcepub fn detect(preferred: BackendKind) -> BackendKind
pub fn detect(preferred: BackendKind) -> BackendKind
Trait Implementations§
Source§impl Clone for BackendFactory
impl Clone for BackendFactory
impl Copy for BackendFactory
Source§impl Debug for BackendFactory
impl Debug for BackendFactory
Auto Trait Implementations§
impl Freeze for BackendFactory
impl RefUnwindSafe for BackendFactory
impl Send for BackendFactory
impl Sync for BackendFactory
impl Unpin for BackendFactory
impl UnsafeUnpin for BackendFactory
impl UnwindSafe for BackendFactory
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
Mutably borrows from an owned value. Read more