Skip to main content

croc_sidecar/
lib.rs

1//! A wrapper for the [Croc] binary.
2//! Set up the binary using builders and listen to events through streams.
3//!
4//! [Croc]: https://github.com/schollz/croc
5//!
6//! # Usage example
7//!
8//! ```no_run,standalone_crate
9//! # use croc_sidecar::Croc;
10//! fn main() -> croc_sidecar::Result {
11//!     let croc = Croc::new()
12//!         .send()
13//!         .code("my-custom-code")
14//!         .file("/path/to/file.rs")
15//!         .spawn()?;
16//! #   Ok(())
17//! }
18//! ```
19//!
20//! To receive a file using a code:
21//!
22//! ```no_run,standalone_crate
23//! # use croc_sidecar::Croc;
24//! fn main() -> croc_sidecar::Result {
25//!     let croc = Croc::new()
26//!         .receive()
27//!         .spawn("my-custom-code")?;
28//! #   Ok(())
29//! }
30//! ```
31//!
32//! You can also listen to `events`:
33//!
34//! ```no_run,standalone_crate
35//! # use futures_util::StreamExt;
36//! # use croc_sidecar::Croc;
37//! # #[tokio::main]
38//! # async fn main() -> croc_sidecar::Result {
39//! let mut croc = Croc::new().send().file("file.rs").spawn()?;
40//!
41//! let mut stream = croc.events()?;
42//! while let Some(event) = stream.next().await {
43//!     match event {
44//!         croc_sidecar::CrocEvent::CodeGenerated(code) => println!("Code is: {code}"),
45//!         croc_sidecar::CrocEvent::Hashing(progress) => println!("Hashing: {}%", progress.percentage),
46//!         croc_sidecar::CrocEvent::Sending(progress) => println!("Sending: {}%", progress.percentage),
47//!         _ => {}
48//!     }
49//! }
50//! # Ok(())
51//! # }
52//! ```
53pub mod croc;
54pub use croc::Croc;
55
56pub mod child;
57pub(crate) use child::CrocChild;
58
59pub mod event;
60pub use event::CrocEvent;
61
62pub mod error;
63pub use error::{Error, Result};
64
65pub mod parser;
66pub(crate) use parser::CrocParser;
67
68pub mod stream;
69pub(crate) use stream::CrocEventStream;