tipsy

Crates.iotipsy
lib.rstipsy
version0.3.1
sourcesrc
created_at2024-05-22 04:26:22.108877
updated_at2024-09-09 00:06:34.16455
descriptionCross-platform IPC for Tokio
homepagehttps://github.com/aschey/tipsy
repositoryhttps://github.com/aschey/tipsy
max_upload_size
id1247467
size57,156
Austin Schey (aschey)

documentation

README

tipsy

crates.io docs.rs Dependency Status license CI codecov GitHub repo size Lines of Code

This is a fork of parity-tokio-ipc.

tipsy is a library for cross-platform async IPC using Tokio. It utilizes unix sockets on UNIX (via tokio::net::UnixStream) and named pipes on windows (via tokio::net::windows::named_pipe).

Server

use tipsy::{Endpoint, OnConflict, ServerId};
use futures::stream::StreamExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    Endpoint::new(ServerId::new("my-server"), OnConflict::Overwrite)?
        .incoming()?
        .for_each(|conn| async {
            match conn {
                Ok(stream) => println!("Got connection!"),
                Err(e) => eprintln!("Error when receiving connection: {:?}", e),
            }
        });
    Ok(())
}

Client

use tipsy::{Endpoint, ServerId};
use tokio::io::AsyncWriteExt;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut client = Endpoint::connect(ServerId::new("my-server")).await?;
    client.write_all(b"ping").await?;
    Ok(())
}

Examples

See examples.

Supported Rust Versions

The MSRV is currently 1.75.0.

Commit count: 193

cargo fmt