Update to test READMEs

pull/195/head v0.20.0-alpha.7
Chip Senkbeil 11 months ago
parent 3225471e28
commit b163094d49
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -1,3 +1,9 @@
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
mod authenticator;
mod handler;
mod methods;

@ -9,18 +9,12 @@
[distant_rustc_img]: https://img.shields.io/badge/distant_core-rustc_1.64+-lightgray.svg
[distant_rustc_lnk]: https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html
Library that powers the [`distant`](https://github.com/chipsenkbeil/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`.
The `distant-core` library supplies the client and server interfaces along with
a client implementation for distant. The library exposes an API that downstream
libraries such as `distant-local` and `distant-ssh2` can implement to provide a
distant-compatible interface.
## Installation
@ -31,31 +25,6 @@ You can import the dependency by adding the following to your `Cargo.toml`:
distant-core = "0.20"
```
## Examples
Below is an example of connecting to a distant server over TCP without any
encryption or authentication:
```rust
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

@ -1,3 +1,9 @@
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
mod api;
pub use api::*;

@ -26,7 +26,7 @@ distant-local = "0.20"
## Examples
```rust
```rust,no_run
// Create a server API handler to be used with the server
let handler = distant_local::initialize_handler().unwrap();
```

@ -1,3 +1,9 @@
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
mod api;
mod constants;
pub use api::LocalDistantApi;

@ -1,3 +1,9 @@
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
mod authentication;
pub mod client;
pub mod common;

@ -1,3 +1,9 @@
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
mod common;
mod msg;
mod request;

@ -26,58 +26,7 @@ You can import the dependency by adding the following to your `Cargo.toml`:
```toml
[dependencies]
distant-ssh2 = "0.19"
```
## Examples
Below is an example of connecting to an ssh server and translating between ssh
protocol and distant protocol:
```rust
use distant_ssh2::{LocalSshAuthHandler, Ssh, SshOpts};
// Using default ssh arguments to establish a connection
let mut ssh = Ssh::connect("example.com", SshOpts::default())
.expect("Failed to connect");
// Authenticating with the server is a separate step
// 1. You can pass the local handler and authentication and host verification
// will be done over stderr
// 2. You can provide your own handlers for programmatic engagement
ssh.authenticate(LocalSshAuthHandler).await
.expect("Failed to authenticate");
// Convert into an ssh client session (no distant server required)
let client = ssh.into_distant_client().await
.expect("Failed to convert into distant client");
```
Below is an example of connecting to an ssh server, spawning a distant server
on the remote machine, and connecting to the distant server:
```rust
use distant_ssh2::{DistantLaunchOpts, LocalSshAuthHandler, Ssh, SshOpts};
// Using default ssh arguments to establish a connection
let mut ssh = Ssh::connect("example.com", SshOpts::default())
.expect("Failed to connect");
// Authenticating with the server is a separate step
// 1. You can pass the local handler and authentication and host verification
// will be done over stderr
// 2. You can provide your own handlers for programmatic engagement
ssh.authenticate(LocalSshAuthHandler).await
.expect("Failed to authenticate");
// Convert into a distant session, which involves spawning a distant server
// using the current ssh connection and then establishing a new connection
// to the distant server
//
// This takes in `DistantLaunchOpts` to specify the server's bin path,
// arguments, timeout, and whether or not to spawn using a login shell
let client = ssh.launch_and_connect(DistantLaunchOpts::default()).await
.expect("Failed to spawn server or connect to it");
distant-ssh2 = "0.20"
```
## License

@ -1,3 +1,9 @@
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
#[cfg(not(any(feature = "libssh", feature = "ssh2")))]
compile_error!("Either feature \"libssh\" or \"ssh2\" must be enabled for this crate.");

@ -1,3 +1,9 @@
#![doc = include_str!("../README.md")]
#[doc = include_str!("../README.md")]
#[cfg(doctest)]
pub struct ReadmeDoctests;
use std::process::{ExitCode, Termination};
use derive_more::{Display, Error, From};

Loading…
Cancel
Save