distant/distant-core
2021-09-28 01:32:06 -05:00
..
src Add missing spawn_lsp method to SessionExt 2021-09-28 01:32:06 -05:00
Cargo.toml Add native ssh (#57) 2021-09-28 00:04:26 -05:00
README.md Add native ssh (#57) 2021-09-28 00:04:26 -05:00

distant core

Crates.io Docs.rs Rustc 1.51.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 library supplies a mixture of functionality and data to run servers that operate on remote machines and clients that talk to them.

Installation

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

[dependencies]
distant-core = "0.14"

Features

Currently, the library supports the following features:

  • structopt: generates StructOpt bindings for RequestData (used by cli to expose request actions)

By default, no features are enabled on the library.

Examples

Below is an example of connecting to a distant server over TCP:

use distant_core::{Request, RequestData, Session, SessionInfo};
use std::path::PathBuf;

// Load our session using the environment variables
//
// DISTANT_HOST     = "..."
// DISTANT_PORT     = "..."
// DISTANT_KEY = "..."
let mut session = Session::tcp_connect(SessionInfo::from_environment()?).await.unwrap();

// Send a request under a specific name and wait for a response
let tenant = "my name";
let req = Request::new(
  tenant, 
  vec![RequestData::FileReadText { path: PathBuf::from("some/path") }]
);

let res = session.send(req).await.unwrap();
println!("Response: {:?}", res);

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.