[−][src]Struct wasi_worker_yew::ServiceWorker
Connects Rust Handler with browser service worker via WASI filesystem.
ServiceWorker is a singleton which holds input and output file handles and owns woker via Handler trait. Worker is supposedly reactive, usually operating on incoming events (on_message) and posting messages to main browser application via ServiceWorker::post_message().
Note: ServiceWorker supposed to operate in single threaded environment like a browser service worker.
TODO: it requires cleaning of filesystem, add drop implementation
Methods
impl ServiceWorker
[src]
pub fn initialize(options: ServiceOptions) -> Result<(), Error>
[src]
Initialize ServiceWorker instance. ServiceWorker operates as singleton, all struct methods are static. Unless initialized all methods will result in error io::ErrorKind::NotConnected.
pub fn set_message_handler(new_handler: Box<dyn Handler + 'static>)
[src]
Message handler is required to process incoming messages. Please note, there is no queue therefore messages received before handler initialized will be lost.
pub fn on_message() -> Result<usize, Error>
[src]
This method is a trigger This is workaround while we don't have wasi::poll_oneoff, ideally we shall just poll and wait for FD_READ event.
pub fn post_message(msg: &[u8]) -> Result<(), Error>
[src]
Post message to external consumers
Example usage:
use wasi_worker::ServiceWorker; ServiceWorker::post_message(b"mymesage");
pub fn kill()
[src]
Trait Implementations
impl Drop for ServiceWorker
[src]
Auto Trait Implementations
impl RefUnwindSafe for ServiceWorker
impl Send for ServiceWorker
impl Sync for ServiceWorker
impl Unpin for ServiceWorker
impl UnwindSafe for ServiceWorker
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
[src]
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,