BREP_stream_client — the BREP CAD application inside your Rust program
Part of the next.BREP.io Rust B-rep kernel: cargo add BREP_stream_client · licence summary
brep-app --stream runs the next.BREP.io CAD application with no window and no
display, and streams its whole user interface (menus, panels, dialogs, the 3D
view) while taking every input. This crate is the native end of that stream:
start the app from Rust, get its picture as RGBA pixels, and send it pointer,
wheel, keyboard, text, clipboard and touch input. Show the pixels in any GUI
toolkit's window, or in none. No browser is involved.
Quick start
The CAD application must be installed: cargo install BREP_app puts
brep-app on your PATH (or use the desktop download from
next.brep.io and give its path).
use ;
use Duration;
// dropping the session ends the app
In a window
A complete eframe (egui) program is on
next.brep.io/developers/embedding.html:
its own side panel, and the CAD session in the rest of the window, drawn 1:1
at the screen's density, following the window's size, with the pointer, wheel,
keys, typed text, the clipboard, touch and the cursor shape passed through. Put
it in src/main.rs of a project with this crate and eframe 0.35.
The pattern carries to any toolkit:
Launcher::new(path).size(w, h, density).launch()starts the app in a child process (--stream 127.0.0.1:0, a private token file, and--stream-until-stdin-closes, so the app never outlives your program).session.set_waker(...)asks your UI to repaint when a frame arrives.- Each repaint,
session.take_update()says which rectangle changed (or that the size did); copy that part ofsession.frame().rgbainto your texture. - Send what happens over your view with
session.send(Input::...), in logical pixels from the view's corner; callsession.resize(w, h, density)when the view's size or the screen's density changes. - Handle
session.poll_events(): the cursor shape, copied text for your clipboard, links to open.
examples/snapshot.rs (cargo run --example snapshot -- /path/to/brep-app) does the same with no window: launch, click, and save
the picture as a PNG.
Attaching to a running session
brep-app --stream ADDR can also run on its own (a server, a container), with a
browser page at http://ADDR/stream/. Client::connect("ADDR", token, options)
attaches to it, with the token from its token file; any number of clients
(and browser pages) can watch, one controls, and take_control() switches.
Plain ws:// only: reach a remote session through an SSH tunnel or a reverse
proxy that ends TLS.
Licence
In plain words: the crates are free to use as they are, including in a commercial project. If you fix or change something in the kernel, send the change back as a pull request to github.com/mmiscool/next.BREP.io_RUST_BREP_KERNEL. If you do not want to share your changes, buy a commercial licence from Autodrop3d LLC; with it you never have to share your code back.
The exact terms are in LICENSE.md, shipped in the crate (license-file in the manifest) and at
LICENSE.md; if this summary and the file ever differ, the file wins.