pub trait SurfaceProducer {
// Required methods
fn resize(&mut self, width: u32, height: u32) -> Result<(), SurfaceError>;
fn set_offset(&mut self, x: i32, y: i32) -> Result<(), SurfaceError>;
fn acquire_frame(&mut self) -> Result<Option<SurfaceFrame>, SurfaceError>;
fn send_mouse_input(&mut self, ev: MouseEvent) -> Result<(), SurfaceError>;
fn send_pointer_input(
&mut self,
ev: PointerEvent,
) -> Result<(), SurfaceError>;
fn send_keyboard_input(
&mut self,
ev: KeyboardEvent,
) -> Result<(), SurfaceError>;
fn move_focus(&mut self, reason: FocusReason) -> Result<(), SurfaceError>;
fn poll_cursor_shape(&mut self) -> Option<CursorShape>;
fn apply_settings(
&mut self,
settings: &SurfaceSettings,
) -> Result<(), SurfaceError>;
fn capture_snapshot_png(&mut self) -> Result<Vec<u8>, SurfaceError>;
// Provided method
fn as_web_surface(&mut self) -> Option<&mut dyn WebSurface> { ... }
}Expand description
Long-lived surface producer. Owns a WebView control until dropped.
All methods take &mut self: the producer is single-owner, driven
sequentially by the host’s render loop. Input flows in through send_*
and move_focus; output flows out through acquire_frame and poll_*.
Not Send: producers may be STA-bound (Windows WebView2 COM) or
main-thread-only (macOS WKWebView, gpui main thread). The host drives them
from a single thread per producer.
Required Methods§
fn resize(&mut self, width: u32, height: u32) -> Result<(), SurfaceError>
fn set_offset(&mut self, x: i32, y: i32) -> Result<(), SurfaceError>
fn acquire_frame(&mut self) -> Result<Option<SurfaceFrame>, SurfaceError>
fn send_mouse_input(&mut self, ev: MouseEvent) -> Result<(), SurfaceError>
fn send_pointer_input(&mut self, ev: PointerEvent) -> Result<(), SurfaceError>
fn send_keyboard_input(&mut self, ev: KeyboardEvent) -> Result<(), SurfaceError>
fn move_focus(&mut self, reason: FocusReason) -> Result<(), SurfaceError>
fn poll_cursor_shape(&mut self) -> Option<CursorShape>
fn apply_settings( &mut self, settings: &SurfaceSettings, ) -> Result<(), SurfaceError>
fn capture_snapshot_png(&mut self) -> Result<Vec<u8>, SurfaceError>
Provided Methods§
fn as_web_surface(&mut self) -> Option<&mut dyn WebSurface>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".