pub trait SurfaceExtWeb: Sized {
// Required methods
fn from_canvas(canvas: HtmlCanvasElement) -> Result<Self, SoftBufferError>;
fn from_offscreen_canvas(
offscreen_canvas: OffscreenCanvas,
) -> Result<Self, SoftBufferError>;
}
Available on WebAssembly only.
Expand description
Extension methods for the Wasm target on Surface
.
Required Methods§
Sourcefn from_canvas(canvas: HtmlCanvasElement) -> Result<Self, SoftBufferError>
fn from_canvas(canvas: HtmlCanvasElement) -> Result<Self, SoftBufferError>
Creates a new instance of this struct, using the provided HtmlCanvasElement
.
§Errors
- If the canvas was already controlled by an
OffscreenCanvas
. - If a another context then “2d” was already created for this canvas.
Sourcefn from_offscreen_canvas(
offscreen_canvas: OffscreenCanvas,
) -> Result<Self, SoftBufferError>
fn from_offscreen_canvas( offscreen_canvas: OffscreenCanvas, ) -> Result<Self, SoftBufferError>
Creates a new instance of this struct, using the provided OffscreenCanvas
.
§Errors
If a another context then “2d” was already created for this canvas.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.