Suck data up through a channel https://docs.rs/suck/latest
Find a file
Roman Moisieiev 4c13facc96
Some checks failed
CI / Run tests (push) Has been cancelled
CI / Lint (push) Has been cancelled
Release-plz / Release-plz release (push) Has been cancelled
Release-plz / Release-plz PR (push) Has been cancelled
Relax T: Clone bound to only apply to static values
2025-10-14 09:17:40 +01:00
.github ci: change build features 2025-09-04 09:42:06 +01:00
src Relax T: Clone bound to only apply to static values 2025-10-14 09:17:40 +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 Allow for completely lock-free access to Static values, and closed channels. 2025-10-14 09:17:40 +01:00
CHANGELOG.md chore: release v0.0.2 2025-09-04 15:21:30 +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 fix: correct toolchain in flake 2025-09-15 10:10:08 +01:00
LICENSE initial commit 2025-09-02 15:35:40 +01:00
README.md feat: add multiple channel providers 2025-09-04 09:42:06 +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

Suck data up through a channel

Crates.io Github Actions Documentation License

Warning

This is unstable, untested and subject to change - use at your own risk.

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::sync::StdSuck;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a pair (using default std backend)
    let (sucker, sourcer) = StdSuck::<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.