suave

Crates.iosuave
lib.rssuave
version0.2.3
sourcesrc
created_at2023-11-23 13:29:49.020963
updated_at2023-11-29 13:02:53.327006
descriptionMulti-process communication utility library.
homepagehttps://github.com/deetonn/suave
repositoryhttps://github.com/deetonn/suave
max_upload_size
id1046139
size37,285
Deeton Rushton (deetonn)

documentation

https://docs.rs/suave/latest/suave/

README

Suave :sunglasses:

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.

Features

Easily create lockfiles

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.

Use shared files to communicate

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);

Use the clipboard to communicate

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...");
Commit count: 30

cargo fmt