#api #async

distant-core

Core library for distant, enabling operation on a remote computer through file and process manipulation

30 releases (7 breaking)

Uses new Rust 2021

0.20.0-alpha.3 Nov 28, 2022
0.19.0 Aug 30, 2022
0.16.4 Jun 7, 2022
0.15.1 Nov 16, 2021

#1893 in Network programming

Download history 45/week @ 2022-10-07 19/week @ 2022-10-14 41/week @ 2022-10-21 36/week @ 2022-10-28 68/week @ 2022-11-04 26/week @ 2022-11-11 85/week @ 2022-11-18 55/week @ 2022-11-25 44/week @ 2022-12-02 63/week @ 2022-12-09 16/week @ 2022-12-16 55/week @ 2022-12-23 23/week @ 2022-12-30 21/week @ 2023-01-06 20/week @ 2023-01-13 30/week @ 2023-01-20

101 downloads per month
Used in 3 crates

MIT/Apache

1MB
27K SLoC

distant core

Crates.io Docs.rs Rustc 1.61.0

Library that powers the distant binary.

🚧 (Alpha stage software) This library is in rapid development and may break or change frequently! 🚧

Details

The distant-core library supplies the client, manager, and server implementations for use with the distant API in order to communicate with remote machines and perform actions. This library acts as the primary implementation that powers the CLI, but is also available for other extensions like distant-ssh2.

Installation

You can import the dependency by adding the following to your Cargo.toml:

[dependencies]
distant-core = "0.19"

Features

Currently, the library supports the following features:

  • clap: generates Clap bindings for DistantRequestData (used by cli to expose request actions)
  • schemars: derives the schemars::JsonSchema interface on DistantMsg, DistantRequestData, and DistantResponseData data types

By default, no features are enabled on the library.

Examples

Below is an example of connecting to a distant server over TCP without any encryption or authentication:

use distant_core::{
  DistantClient,
  DistantChannelExt,
  net::{PlainCodec, TcpClientExt},
};
use std::{net::SocketAddr, path::Path};

// Connect to a server located at example.com on port 8080 that is using
// no encryption or authentication (PlainCodec)
let addr: SocketAddr = "example.com:8080".parse().unwrap();
let mut client = DistantClient::connect(addr, PlainCodec).await
  .expect("Failed to connect");

// Append text to a file
// NOTE: This method comes from DistantChannelExt
client.append_file_text(Path::new("path/to/file.txt"), "new contents").await
  .expect("Failed to append to file");

License

This project is licensed under either of

Apache License, Version 2.0, (LICENSE-APACHE or apache-license) MIT license (LICENSE-MIT or mit-license) at your option.

Dependencies

~14–21MB
~436K SLoC