[−][src]Struct alcro::UI
The browser window
Implementations
impl UI
[src]
pub fn done(&self) -> bool
[src]
Returns true if the browser is closed
pub fn wait_finish(&self)
[src]
Wait for the browser to be closed
pub fn close(&self)
[src]
Close the browser window
pub fn load(&self, content: Content) -> JSResult
[src]
Load content in the browser. It returns Err if it fails.
pub fn bind<F>(&self, name: &str, f: F) -> JSResult where
F: Fn(&[JSObject]) -> JSResult + Sync + Send + 'static,
[src]
F: Fn(&[JSObject]) -> JSResult + Sync + Send + 'static,
Bind a rust function so that JS code can use it. It returns Err if it fails.
Arguments
name
- Name of the functionf
- The function. It should take a list ofJSObject
as argument and return aJSResult
Examples
#![windows_subsystem = "windows"] use alcro::UIBuilder; use serde_json::to_value; let ui = UIBuilder::new().custom_args(&["--headless"]).run(); ui.bind("add", |args| { let mut sum = 0; for arg in args { if arg.is_i64() { sum += arg.as_i64().unwrap(); } else { return Err(to_value("Not a number").unwrap()); } } Ok(to_value(sum).unwrap()) }).unwrap(); assert_eq!(ui.eval("(async () => await add(1,2,3))();").unwrap(), 6); assert!(ui.eval("(async () => await add(1,2,'hi'))();").is_err());
pub fn eval(&self, js: &str) -> JSResult
[src]
Evaluates js code and returns the result.
Examples
#![windows_subsystem = "windows"] use alcro::UIBuilder; let ui = UIBuilder::new().custom_args(&["--headless"]).run(); assert_eq!(ui.eval("1+1").unwrap(), 2); assert_eq!(ui.eval("'Hello'+' World'").unwrap(), "Hello World"); assert!(ui.eval("xfgch").is_err());
pub fn set_bounds(&self, b: Bounds) -> JSResult
[src]
It changes the size, position or state of the browser window specified by the Bounds
struct. It returns Err if it fails.
To change the window state alone use WindowState::to_bounds()
pub fn bounds(&self) -> Result<Bounds, JSObject>
[src]
It gets the size, position and state of the browser window. It returns Err if it fails.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> Typeable for T where
T: Any,
T: Any,