Suck data up through a channel https://docs.rs/suck/latest
Find a file
2025-09-02 21:48:08 +01:00
.github initial commit 2025-09-02 15:35:40 +01:00
src test: add basic tests for synchronous channel 2025-09-02 21:47:44 +01:00
.envrc initial commit 2025-09-02 15:35:40 +01:00
.gitignore initial commit 2025-09-02 15:35:40 +01:00
Cargo.toml initial commit 2025-09-02 15:35:40 +01:00
cliff.toml initial commit 2025-09-02 15:35:40 +01:00
flake.lock initial commit 2025-09-02 15:35:40 +01:00
flake.nix chore: add nextest to dev environment 2025-09-02 15:41:38 +01:00
LICENSE initial commit 2025-09-02 15:35:40 +01:00
README.md docs: populate README 2025-09-02 21:48:08 +01:00
release-plz.toml initial commit 2025-09-02 15:35:40 +01:00
rust-toolchain.toml initial commit 2025-09-02 15:35:40 +01:00
rustfmt.toml initial commit 2025-09-02 15:35:40 +01:00

suck

Crates.io Github Actions Documentation License

Suck data up through a channel

Features

  • Pull-based communication: Consumers request values on-demand
  • Contextual values: Designed for current state rather than event streams
  • Flexible sources: Support both static values and dynamic closures

Installation

Add this to your Cargo.toml:

[dependencies]
suck = "*"

Quick Start

use suck::SuckPair;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a pair
    let (sucker, sourcer) = SuckPair::<i32>::pair();

    // Start producer in a thread
    let producer = std::thread::spawn(move || {
        // Set a static value
        sourcer.set_static(42).unwrap();

        // Or set a dynamic closure
        sourcer.set(|| {
            // Generate fresh values each time
            42 * 2
        }).unwrap();

        // Run the producer loop
        sourcer.run().unwrap();
    });

    // Consumer pulls values
    let value = sucker.get()?;
    println!("Got value: {}", value);

    // Clean up
    sucker.close()?;
    producer.join().unwrap();

    Ok(())
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.