Clean up warnings for distant-core, add distant-core readme, and initial Github action ci

pull/39/head
Chip Senkbeil 3 years ago
parent ec4f635dbe
commit 20f8b13f4d
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -0,0 +1,98 @@
on: [push]
name: Core CI
jobs:
test-core:
name: Test Rust ${{ matrix.rust }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { rust: stable, os: ubuntu-latest }
- { rust: stable, os: macos-latest }
- { rust: stable, os: windows-latest }
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Check Cargo availability
run: cargo --version
- run: cargo test --verbose -p distant-core
- run: cargo test --verbose --all-features -p distant-core
test-cli:
name: Test Rust ${{ matrix.rust }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { rust: stable, os: ubuntu-latest }
- { rust: stable, os: macos-latest }
- { rust: stable, os: windows-latest }
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.rust }}
- name: Check Cargo availability
run: cargo --version
- run: cargo test --verbose
clippy:
name: Lint with clippy
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: hecrj/setup-rust-action@v1
with:
components: clippy
- name: Check Cargo availability
run: cargo --version
- run: cargo clippy --workspace --all-targets --verbose
- run: cargo clippy --workspace --all-targets --verbose --all-features
rustfmt:
name: Verify code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: hecrj/setup-rust-action@v1
with:
components: rustfmt
- name: Check Cargo availability
run: cargo --version
- run: cargo fmt --all -- --check

@ -0,0 +1,73 @@
# distant core
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` library supplies a mixture of functionality and data to run
servers that operate on remote machines and clients that talk to them.
- Asynchronous in nature, powered by [`tokio`](https://tokio.rs/)
- Data is serialized to send across the wire via [`CBOR`](https://cbor.io/)
- Encryption & authentication are handled via [`orion`](https://crates.io/crates/orion)
- [XChaCha20Poly1305](https://cryptopp.com/wiki/XChaCha20Poly1305) for an authenticated encryption scheme
- [BLAKE2b-256](https://www.blake2.net/) in keyed mode for a second authentication
- [Elliptic Curve Diffie-Hellman](https://en.wikipedia.org/wiki/Elliptic-curve_Diffie%E2%80%93Hellman) (ECDH) for key exchange
## Installation
You can import the dependency by adding the following to your `Cargo.toml`:
```toml
[dependencies]
distant-core = "0.13"
```
## Features
Currently, the library supports the following features:
- `structopt`: generates [`StructOpt`](https://github.com/TeXitoi/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:
```rust
use distant_core::{Request, RequestData, Session, SessionInfo};
use std::path::PathBuf;
// Load our session using the environment variables
//
// DISTANT_HOST = "..."
// DISTANT_PORT = "..."
// DISTANT_AUTH_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][apache-license]) MIT license (LICENSE-MIT or
[mit-license][mit-license]) at your option.
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
[mit-license]: http://opensource.org/licenses/MIT

@ -9,6 +9,7 @@ use strum::AsRefStr;
/// with structopt rather than trying to parse a string as a singular u8
pub type ByteVec = Vec<u8>;
#[cfg(feature = "structopt")]
fn parse_byte_vec(src: &str) -> ByteVec {
src.as_bytes().to_vec()
}

Loading…
Cancel
Save