switch back to crossterm + cargo-deny stuff

This commit is contained in:
Michael Zhang 2021-03-01 03:13:25 -06:00
parent 09eafd0f3f
commit e5515f6c7c
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
8 changed files with 291 additions and 933 deletions

View file

@ -17,3 +17,4 @@ jobs:
- name: run tests
run: |
cargo test --all

987
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ license = "GPL-3.0-or-later"
members = ["imap", "smtp"]
[dependencies]
# crossterm = "0.19.0"
crossterm = "0.19.0"
anyhow = "1.0.38"
async-trait = "0.1.42"
cfg-if = "1.0.0"
@ -24,9 +24,7 @@ inotify = { version = "0.9.2", features = ["stream"] }
log = "0.4.14"
notify-rust = { version = "4.2.2", default-features = false, features = ["z"] }
parking_lot = "0.11.1"
pgp = "0.7.1"
pin-project = "1.0.5"
rustls-connector = "0.13.1"
# pgp = "0.7.1"
serde = { version = "1.0.123", features = ["derive"] }
structopt = "0.3.21"
tokio = { version = "1.2.0", features = ["full"] }
@ -34,11 +32,9 @@ tokio-rustls = "0.22.0"
tokio-stream = { version = "0.1.3", features = ["sync"] }
tokio-util = { version = "0.6.3", features = ["full"] }
toml = "0.5.8"
# tui = { version = "0.14.0", default-features = false, features = ["crossterm"] }
tui = { version = "0.14.0", default-features = false, features = ["crossterm"] }
webpki-roots = "0.21.0"
xdg = "2.2.0"
tui = "0.14.0"
termion = "1.5.6"
[dependencies.panorama-imap]
path = "imap"

177
deny.toml Normal file
View file

@ -0,0 +1,177 @@
# This template contains all of the possible sections and their default values
# Note that all fields that take a lint level have these possible values:
# * deny - An error will be produced and the check will fail
# * warn - A warning will be produced, but the check will not fail
# * allow - No warning or error will be produced, though in some cases a note
# will be
# The values provided in this template are the default values that will be used
# when any section or field is not specified in your own configuration
# If 1 or more target triples (and optionally, target_features) are specified,
# only the specified targets will be checked when running `cargo deny check`.
# This means, if a particular package is only ever used as a target specific
# dependency, such as, for example, the `nix` crate only being used via the
# `target_family = "unix"` configuration, that only having windows targets in
# this list would mean the nix crate, as well as any of its exclusive
# dependencies not shared by any other crates, would be ignored, as the target
# list here is effectively saying which targets you are building for.
targets = [
{ triple = "x86_64-unknown-linux-gnu" },
]
# This section is considered when running `cargo deny check advisories`
# More documentation for the advisories section can be found here:
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
[advisories]
# The path where the advisory database is cloned/fetched into
db-path = "~/.cargo/advisory-db"
# The url(s) of the advisory databases to use
db-urls = ["https://github.com/rustsec/advisory-db"]
# The lint level for security vulnerabilities
vulnerability = "deny"
# The lint level for unmaintained crates
unmaintained = "warn"
# The lint level for crates that have been yanked from their source registry
yanked = "warn"
# The lint level for crates with security notices. Note that as of
# 2019-12-17 there are no security notice advisories in
# https://github.com/rustsec/advisory-db
notice = "warn"
# A list of advisory IDs to ignore. Note that ignored advisories will still
# output a note when they are encountered.
ignore = [
#"RUSTSEC-0000-0000",
]
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
# lower than the range specified will be ignored. Note that ignored advisories
# will still output a note when they are encountered.
# * None - CVSS Score 0.0
# * Low - CVSS Score 0.1 - 3.9
# * Medium - CVSS Score 4.0 - 6.9
# * High - CVSS Score 7.0 - 8.9
# * Critical - CVSS Score 9.0 - 10.0
#severity-threshold =
# This section is considered when running `cargo deny check licenses`
# More documentation for the licenses section can be found here:
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
[licenses]
unlicensed = "deny"
allow = [
#"MIT",
#"Apache-2.0",
#"Apache-2.0 WITH LLVM-exception",
]
deny = [ ]
copyleft = "allow"
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
# * both - The license will be approved if it is both OSI-approved *AND* FSF
# * either - The license will be approved if it is either OSI-approved *OR* FSF
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF
# * fsf-only - The license will be approved if is FSF *AND NOT* OSI-approved
# * neither - This predicate is ignored and the default lint level is used
allow-osi-fsf-free = "either"
# Lint level used when no other predicates are matched
# 1. License isn't in the allow or deny lists
# 2. License isn't copyleft
# 3. License isn't OSI/FSF, or allow-osi-fsf-free = "neither"
default = "deny"
# The confidence threshold for detecting a license from license text.
# The higher the value, the more closely the license text must be to the
# canonical license text of a valid SPDX license file.
# [possible values: any between 0.0 and 1.0].
confidence-threshold = 0.8
# Allow 1 or more licenses on a per-crate basis, so that particular licenses
# aren't accepted for every possible crate as with the normal allow list
exceptions = [
# Each entry is the crate and version constraint, and its specific allow
# list
#{ allow = ["Zlib"], name = "adler32", version = "*" },
]
# Some crates don't have (easily) machine readable licensing information,
# adding a clarification entry for it allows you to manually specify the
# licensing information
[[licenses.clarify]]
name = "ring"
version = "*"
expression = "MIT AND ISC AND OpenSSL"
license-files = [
{ path = "LICENSE", hash = 0xbd0eed23 }
]
# The SPDX expression for the license requirements of the crate
# One or more files in the crate's source used as the "source of truth" for
# the license expression. If the contents match, the clarification will be used
# when running the license check, otherwise the clarification will be ignored
# and the crate will be checked normally, which may produce warnings or errors
# depending on the rest of your configuration
[licenses.private]
# If true, ignores workspace crates that aren't published, or are only
# published to private registries
ignore = false
# One or more private registries that you might publish crates to, if a crate
# is only published to private registries, and ignore is true, the crate will
# not have its license(s) checked
registries = [
#"https://sekretz.com/registry
]
# This section is considered when running `cargo deny check bans`.
# More documentation about the 'bans' section can be found here:
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
[bans]
# Lint level for when multiple versions of the same crate are detected
multiple-versions = "warn"
# Lint level for when a crate version requirement is `*`
wildcards = "allow"
# The graph highlighting used when creating dotgraphs for crates
# with multiple versions
# * lowest-version - The path to the lowest versioned duplicate is highlighted
# * simplest-path - The path to the version with the fewest edges is highlighted
# * all - Both lowest-version and simplest-path are used
highlight = "all"
# List of crates that are allowed. Use with care!
allow = [
#{ name = "ansi_term", version = "=0.11.0" },
]
# List of crates to deny
deny = [
# Each entry the name of a crate and a version range. If version is
# not specified, all versions will be matched.
#{ name = "ansi_term", version = "=0.11.0" },
#
# Wrapper crates can optionally be specified to allow the crate when it
# is a direct dependency of the otherwise banned crate
#{ name = "ansi_term", version = "=0.11.0", wrappers = [] },
]
# Certain crates/versions that will be skipped when doing duplicate detection.
skip = [
#{ name = "ansi_term", version = "=0.11.0" },
]
# Similarly to `skip` allows you to skip certain crates during duplicate
# detection. Unlike skip, it also includes the entire tree of transitive
# dependencies starting at the specified crate, up to a certain depth, which is
# by default infinite
skip-tree = [
#{ name = "ansi_term", version = "=0.11.0", depth = 20 },
]
# This section is considered when running `cargo deny check sources`.
# More documentation about the 'sources' section can be found here:
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
[sources]
# Lint level for what to happen when a crate from a crate registry that is not
# in the allow list is encountered
unknown-registry = "warn"
# Lint level for what to happen when a crate from a git repository that is not
# in the allow list is encountered
unknown-git = "warn"
# List of URLs for allowed crate registries. Defaults to the crates.io index
# if not specified. If it is specified but empty, no registries are allowed.
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
# List of URLs for allowed Git repositories
allow-git = []

View file

@ -5,7 +5,7 @@ authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>", "Michael Zhang <mail@mzhang.i
description = "IMAP protocol parser and data structures"
keywords = ["imap", "email"]
categories = ["email", "network-programming", "parser-implementations"]
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
edition = "2018"
[badges]
@ -18,7 +18,6 @@ anyhow = "1.0.38"
async-trait = "0.1.42"
derive_builder = "0.9.0"
futures = "0.3.12"
genawaiter = { version = "0.99.1", features = ["futures03"] }
log = "0.4.14"
parking_lot = "0.11.1"
pest = "2.1.3"

View file

@ -3,5 +3,6 @@ name = "panorama-smtp"
version = "0.1.0"
authors = ["Michael Zhang <mail@mzhang.io>"]
edition = "2018"
license = "GPL-3.0-or-later"
[dependencies]

View file

@ -8,8 +8,8 @@
#[macro_use]
extern crate anyhow;
// #[macro_use]
// extern crate crossterm;
#[macro_use]
extern crate crossterm;
#[macro_use]
extern crate format_bytes;
#[macro_use]

View file

@ -1,32 +1,27 @@
//! UI library
mod events;
use std::io::Stdout;
use std::time::Duration;
use anyhow::Result;
use termion::{event::Key, screen::AlternateScreen};
use tokio::sync::mpsc;
use tui::{
backend::TermionBackend,
text::Spans,
backend::CrosstermBackend,
layout::{Constraint, Direction, Layout},
widgets::{Block, Borders, Widget},
widgets::*,
Terminal,
};
use self::events::{Config, Event, Events};
/// Main entrypoint for the UI
pub async fn run_ui(stdout: Stdout, exit_tx: mpsc::Sender<()>) -> Result<()> {
let stdout = AlternateScreen::from(stdout);
let backend = TermionBackend::new(stdout);
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
let events = Events::with_config(Config {
tick_rate: Duration::from_millis(17),
..Config::default()
});
// let events = Events::with_config(Config {
// tick_rate: Duration::from_millis(17),
// ..Config::default()
// });
loop {
terminal.draw(|f| {
@ -46,16 +41,20 @@ pub async fn run_ui(stdout: Stdout, exit_tx: mpsc::Sender<()>) -> Result<()> {
f.render_widget(block, chunks[0]);
let block = Block::default().title("Block 2").borders(Borders::ALL);
f.render_widget(block, chunks[1]);
let titles = vec!["hellosu"].into_iter().map(Spans::from).collect();
let tabs = Tabs::new(titles);
f.render_widget(tabs, chunks[2]);
})?;
if let Event::Input(input) = events.next()? {
match input {
Key::Char('q') => {
break;
}
_ => {}
}
}
// if let Event::Input(input) = events.next()? {
// match input {
// Key::Char('q') => {
// break;
// }
// _ => {}
// }
// }
}
Ok(())