Crates.io | suave |
lib.rs | suave |
version | 0.2.3 |
source | src |
created_at | 2023-11-23 13:29:49.020963 |
updated_at | 2023-11-29 13:02:53.327006 |
description | Multi-process communication utility library. |
homepage | https://github.com/deetonn/suave |
repository | https://github.com/deetonn/suave |
max_upload_size | |
id | 1046139 |
size | 37,285 |
Multi-process and interprocess communication library focused on getting things up and working. It is 100% async and written in pure rust.
Any and all methods should be supported and they are being added all the time. Come get involved.
NOTE: The queue
feature is not yet stable.
NOTE: This implementation requires no actual reading or writing.
use suave::pipe::LockFile;
let lockfile = LockFile::temp().await?;
{
let lock = lockfile.lock().await?;
// locked within this scope.
eprintln!("Woohoo, its locked!");
} // unlocked on Drop.
This implementation uses LockFile
internally to sync writing.
use suave::pipe::NamedPipe;
// connect to this shared resource
let pipe = NamedPipe::connect("shared_resource").await?;
// aqquire the lock and write "Hello, World!"
let nbytes = pipe.write(b"Hello, World!").await?;
eprintln!("wrote {} bytes to our shared resource!", nbytes);
This implementation uses LockFile
internally to sync writing.
use suave::clipboard::Clipboard;
let clipboard = Clipboard::connect().await?;
let contents = clipboard.read()?;
eprintln!("initial contents: {}", contents);
clipboard.write("Something...", WriteKind::Guarantee).await?;
// Alternate way to just read clipboard contents, due to reading not needed a lock.
let new_contents = Clipboard::contents()?;
assert_eq!(new_contents, "Something...");