pub struct EvalCommand {
pub script: String,
pub response_tx: Sender<EvalResponse>,
}Expand description
Command sent from HTTP server to Dioxus app for JavaScript evaluation.
When the bridge receives an eval request, it creates an EvalCommand and sends it
through the channel. The Dioxus app should poll this channel and execute the script.
§Example
ⓘ
while let Some(cmd) = eval_rx.recv().await {
let result = document::eval(&cmd.script).await;
let response = match result {
Ok(val) => EvalResponse::success(val.to_string()),
Err(e) => EvalResponse::error(e.to_string()),
};
let _ = cmd.response_tx.send(response);
}Fields§
§script: StringThe JavaScript code to execute in the webview.
response_tx: Sender<EvalResponse>Channel to send the evaluation result back to the HTTP handler.
Auto Trait Implementations§
impl Freeze for EvalCommand
impl !RefUnwindSafe for EvalCommand
impl Send for EvalCommand
impl Sync for EvalCommand
impl Unpin for EvalCommand
impl !UnwindSafe for EvalCommand
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