Expand description
A wrapper for the Croc binary. Set up the binary using builders and listen to events through streams.
§Usage example
fn main() -> croc_sidecar::Result {
let croc = Croc::new()
.send()
.code("my-custom-code")
.file("/path/to/file.rs")
.spawn()?;
}To receive a file using a code:
fn main() -> croc_sidecar::Result {
let croc = Croc::new()
.receive()
.spawn("my-custom-code")?;
}You can also listen to events:
let mut croc = Croc::new().send().file("file.rs").spawn()?;
let mut stream = croc.events()?;
while let Some(event) = stream.next().await {
match event {
croc_sidecar::CrocEvent::CodeGenerated(code) => println!("Code is: {code}"),
croc_sidecar::CrocEvent::Hashing(progress) => println!("Hashing: {}%", progress.percentage),
croc_sidecar::CrocEvent::Sending(progress) => println!("Sending: {}%", progress.percentage),
_ => {}
}
}