pub struct Launcher { /* private fields */ }Expand description
Starts brep-app --stream as a child process and connects to it.
Implementations§
Source§impl Launcher
impl Launcher
Sourcepub fn new(program: impl AsRef<OsStr>) -> Launcher
pub fn new(program: impl AsRef<OsStr>) -> Launcher
Run program ("brep-app" on the PATH, or a path to it).
Examples found in repository?
examples/snapshot.rs (line 12)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let program = std::env::args().nth(1).unwrap_or_else(|| "brep-app".into());
10 let started = Instant::now();
11 // 1280 x 800 logical pixels at density 1. The app ends with the session.
12 let session = Launcher::new(&program).size(1280.0, 800.0, 1.0).launch()?;
13 session.wait_still(Duration::from_millis(1500), Duration::from_secs(120))?;
14 let (width, height) = {
15 let frame = session.frame();
16 (frame.width, frame.height)
17 };
18 println!("ready in {:.1} s: {width} x {height} pixels", started.elapsed().as_secs_f32());
19
20 // The File menu sits at (148, 19) in the default layout.
21 let (x, y) = (148.0, 19.0);
22 let clicked = Instant::now();
23 session.send(Input::PointerMove { x, y });
24 session.send(Input::Button { x, y, button: PointerButton::Primary, down: true, mods: Mods::NONE });
25 session.send(Input::Button { x, y, button: PointerButton::Primary, down: false, mods: Mods::NONE });
26 session.wait_frame(Duration::from_secs(10))?;
27 println!("the click came back as a new frame in {} ms", clicked.elapsed().as_millis());
28 session.wait_still(Duration::from_millis(500), Duration::from_secs(30))?;
29
30 {
31 let frame = session.frame();
32 image::save_buffer("brep-cad.png", &frame.rgba, frame.width, frame.height, image::ColorType::Rgba8)?;
33 println!("saved brep-cad.png after {} frames", frame.frames);
34 }
35 let status = session.shutdown(Duration::from_secs(15))?;
36 println!("the app exited: {status}");
37 Ok(())
38}Sourcepub fn from_command(command: Command) -> Launcher
pub fn from_command(command: Command) -> Launcher
Run this command, with its own arguments (a document to open, --mcp
for an AI agent beside you), environment and working directory. The
launcher adds the --stream switches and takes its stdin and stdout.
Sourcepub fn size(self, width: f32, height: f32, density: f32) -> Launcher
pub fn size(self, width: f32, height: f32, density: f32) -> Launcher
The session’s size in logical pixels and its density.
Examples found in repository?
examples/snapshot.rs (line 12)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let program = std::env::args().nth(1).unwrap_or_else(|| "brep-app".into());
10 let started = Instant::now();
11 // 1280 x 800 logical pixels at density 1. The app ends with the session.
12 let session = Launcher::new(&program).size(1280.0, 800.0, 1.0).launch()?;
13 session.wait_still(Duration::from_millis(1500), Duration::from_secs(120))?;
14 let (width, height) = {
15 let frame = session.frame();
16 (frame.width, frame.height)
17 };
18 println!("ready in {:.1} s: {width} x {height} pixels", started.elapsed().as_secs_f32());
19
20 // The File menu sits at (148, 19) in the default layout.
21 let (x, y) = (148.0, 19.0);
22 let clicked = Instant::now();
23 session.send(Input::PointerMove { x, y });
24 session.send(Input::Button { x, y, button: PointerButton::Primary, down: true, mods: Mods::NONE });
25 session.send(Input::Button { x, y, button: PointerButton::Primary, down: false, mods: Mods::NONE });
26 session.wait_frame(Duration::from_secs(10))?;
27 println!("the click came back as a new frame in {} ms", clicked.elapsed().as_millis());
28 session.wait_still(Duration::from_millis(500), Duration::from_secs(30))?;
29
30 {
31 let frame = session.frame();
32 image::save_buffer("brep-cad.png", &frame.rgba, frame.width, frame.height, image::ColorType::Rgba8)?;
33 println!("saved brep-cad.png after {} frames", frame.frames);
34 }
35 let status = session.shutdown(Duration::from_secs(15))?;
36 println!("the app exited: {status}");
37 Ok(())
38}Sourcepub fn ready_timeout(self, timeout: Duration) -> Launcher
pub fn ready_timeout(self, timeout: Duration) -> Launcher
How long the app may take to start (default two minutes).
Sourcepub fn launch(self) -> Result<Session, Error>
pub fn launch(self) -> Result<Session, Error>
Start the app and connect as the controlling client.
Examples found in repository?
examples/snapshot.rs (line 12)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let program = std::env::args().nth(1).unwrap_or_else(|| "brep-app".into());
10 let started = Instant::now();
11 // 1280 x 800 logical pixels at density 1. The app ends with the session.
12 let session = Launcher::new(&program).size(1280.0, 800.0, 1.0).launch()?;
13 session.wait_still(Duration::from_millis(1500), Duration::from_secs(120))?;
14 let (width, height) = {
15 let frame = session.frame();
16 (frame.width, frame.height)
17 };
18 println!("ready in {:.1} s: {width} x {height} pixels", started.elapsed().as_secs_f32());
19
20 // The File menu sits at (148, 19) in the default layout.
21 let (x, y) = (148.0, 19.0);
22 let clicked = Instant::now();
23 session.send(Input::PointerMove { x, y });
24 session.send(Input::Button { x, y, button: PointerButton::Primary, down: true, mods: Mods::NONE });
25 session.send(Input::Button { x, y, button: PointerButton::Primary, down: false, mods: Mods::NONE });
26 session.wait_frame(Duration::from_secs(10))?;
27 println!("the click came back as a new frame in {} ms", clicked.elapsed().as_millis());
28 session.wait_still(Duration::from_millis(500), Duration::from_secs(30))?;
29
30 {
31 let frame = session.frame();
32 image::save_buffer("brep-cad.png", &frame.rgba, frame.width, frame.height, image::ColorType::Rgba8)?;
33 println!("saved brep-cad.png after {} frames", frame.frames);
34 }
35 let status = session.shutdown(Duration::from_secs(15))?;
36 println!("the app exited: {status}");
37 Ok(())
38}Auto Trait Implementations§
impl !RefUnwindSafe for Launcher
impl !UnwindSafe for Launcher
impl Forget for Launcher
impl Freeze for Launcherwhere
*const [u8] is !null: Freeze,
PhantomData<[u8]>: Freeze,
*const u8 is !null: Freeze,
PhantomData<*const i8>: Freeze,
*const LeafNode<OsString, Option<OsString>> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(OsString, Option<OsString>)>>: Freeze,
PhantomData<Box<dyn FnMut() -> Result<(), Error> + Sync + Send>>: Freeze,
*const [u32] is !null: Freeze,
PhantomData<[u32]>: Freeze,
I32NotAllOnes: Freeze,
PhantomData<&'static OwnedFd>: Freeze,
impl Move for Launcher
impl Send for Launcherwhere
BoxRaw<[u8]>: Send,
CStringArray: Send,
NodeRef<Owned, OsString, Option<OsString>, LeafOrInternal>: Send,
BoxRaw<(OsString, Option<OsString>)>: Send,
RawVecInner: Send,
BoxRaw<dyn FnMut() -> Result<(), Error> + Sync + Send>: Send,
BoxRaw<[u32]>: Send,
I32NotAllOnes: Send,
&'static OwnedFd: Send,
impl Sync for Launcher
impl Unpin for Launcher
impl UnsafeUnpin for Launcherwhere
*const [u8] is !null: UnsafeUnpin,
PhantomData<[u8]>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<*const i8>: UnsafeUnpin,
*const LeafNode<OsString, Option<OsString>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(OsString, Option<OsString>)>>: UnsafeUnpin,
PhantomData<Box<dyn FnMut() -> Result<(), Error> + Sync + Send>>: UnsafeUnpin,
*const [u32] is !null: UnsafeUnpin,
PhantomData<[u32]>: UnsafeUnpin,
I32NotAllOnes: UnsafeUnpin,
PhantomData<&'static OwnedFd>: UnsafeUnpin,
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