generated from PlexSheep/baserepo
Automatical formatting
This commit is contained in:
parent
6dcc45d722
commit
43ac1e3fb8
|
@ -19,7 +19,7 @@ use libpt::ccc::*;
|
||||||
use libpt::log::*;
|
use libpt::log::*;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use clap_verbosity_flag::{Verbosity, InfoLevel};
|
use clap_verbosity_flag::{InfoLevel, Verbosity};
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ pub struct Cli {
|
||||||
pub log_meta: bool,
|
pub log_meta: bool,
|
||||||
|
|
||||||
/// your exporession(s)
|
/// your exporession(s)
|
||||||
#[clap(trailing_var_arg=true)]
|
#[clap(trailing_var_arg = true)]
|
||||||
pub expression: Vec<String>,
|
pub expression: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
use clap_num::number_range;
|
use clap_num::number_range;
|
||||||
|
|
||||||
use clap_verbosity_flag::{Verbosity, InfoLevel};
|
use clap_verbosity_flag::{InfoLevel, Verbosity};
|
||||||
|
|
||||||
//// CONSTANTS /////////////////////////////////////////////////////////////////////////////////////
|
//// CONSTANTS /////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// short about section displayed in help
|
/// short about section displayed in help
|
||||||
|
@ -103,13 +103,10 @@ pub enum NetCommands {
|
||||||
|
|
||||||
/// set a timeout (in ms)
|
/// set a timeout (in ms)
|
||||||
#[clap(short, long, default_value_t = 100)]
|
#[clap(short, long, default_value_t = 100)]
|
||||||
timeout: u64
|
timeout: u64,
|
||||||
|
|
||||||
},
|
},
|
||||||
/// discover hosts in your network
|
/// discover hosts in your network
|
||||||
Discover {
|
Discover {},
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// enable clippy's extra lints, the pedantic version
|
// enable clippy's extra lints, the pedantic version
|
||||||
#![warn(clippy::pedantic)]
|
#![warn(clippy::pedantic)]
|
||||||
|
|
||||||
|
|
||||||
//// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
|
//// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
|
||||||
use libpt::{log::*, net::monitoring::uptime};
|
use libpt::{log::*, net::monitoring::uptime};
|
||||||
|
|
||||||
|
@ -26,7 +25,6 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
//// CONSTANTS /////////////////////////////////////////////////////////////////////////////////////
|
//// CONSTANTS /////////////////////////////////////////////////////////////////////////////////////
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
||||||
//// STATICS ///////////////////////////////////////////////////////////////////////////////////////
|
//// STATICS ///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//// MACROS ////////////////////////////////////////////////////////////////////////////////////////
|
//// MACROS ////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -20,7 +20,8 @@ macro_rules! investigate_memory_layout {
|
||||||
let pointer = item as *const $t;
|
let pointer = item as *const $t;
|
||||||
let mut memory: [u8; std::mem::size_of::<$t>()] = std::mem::transmute(item.clone());
|
let mut memory: [u8; std::mem::size_of::<$t>()] = std::mem::transmute(item.clone());
|
||||||
memory.reverse();
|
memory.reverse();
|
||||||
println!("\
|
println!(
|
||||||
|
"\
|
||||||
\t{index:02x}\titem:\t\t{item:?}\n\
|
\t{index:02x}\titem:\t\t{item:?}\n\
|
||||||
\t\tpointer: \t{:X?}\n\
|
\t\tpointer: \t{:X?}\n\
|
||||||
\t\talign: \t{}\n\
|
\t\talign: \t{}\n\
|
||||||
|
|
|
@ -59,8 +59,7 @@ where
|
||||||
return format!("{:.2} Z", total.to_f64().unwrap() / ZEBI as f64);
|
return format!("{:.2} Z", total.to_f64().unwrap() / ZEBI as f64);
|
||||||
} else if YOBI <= total {
|
} else if YOBI <= total {
|
||||||
return format!("{:.2} Y", total.to_f64().unwrap() / YOBI as f64);
|
return format!("{:.2} Y", total.to_f64().unwrap() / YOBI as f64);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use libpt_bintols::*;
|
|
||||||
use libpt_bintols::display::*;
|
use libpt_bintols::display::*;
|
||||||
|
use libpt_bintols::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn btobin() {
|
fn btobin() {
|
||||||
|
@ -10,11 +10,16 @@ fn btobin() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn big_btobin() {
|
fn big_btobin() {
|
||||||
let data = [12,31,82,32,123,32,92,23,12,32,12,1,1,1];
|
let data = [12, 31, 82, 32, 123, 32, 92, 23, 12, 32, 12, 1, 1, 1];
|
||||||
let r = bytes_to_bin(&data);
|
let r = bytes_to_bin(&data);
|
||||||
assert_eq!(r, format!("0b00001100_00011111_01010010_\
|
assert_eq!(
|
||||||
|
r,
|
||||||
|
format!(
|
||||||
|
"0b00001100_00011111_01010010_\
|
||||||
00100000_01111011_00100000_01011100_00010111_00001100\n\
|
00100000_01111011_00100000_01011100_00010111_00001100\n\
|
||||||
_00100000_00001100_00000001_00000001_00000001"));
|
_00100000_00001100_00000001_00000001_00000001"
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -29,35 +34,35 @@ fn hmnbytes() {
|
||||||
assert_eq!(humanbytes(0), format!("0 B"));
|
assert_eq!(humanbytes(0), format!("0 B"));
|
||||||
assert_eq!(humanbytes(1), format!("1 B"));
|
assert_eq!(humanbytes(1), format!("1 B"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(KIBI-1), format!("1023 B"));
|
assert_eq!(humanbytes(KIBI - 1), format!("1023 B"));
|
||||||
assert_eq!(humanbytes(KIBI), format!("1.00 K"));
|
assert_eq!(humanbytes(KIBI), format!("1.00 K"));
|
||||||
assert_eq!(humanbytes(KIBI+1), format!("1.00 K"));
|
assert_eq!(humanbytes(KIBI + 1), format!("1.00 K"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(MEBI-1), format!("1024.00 K"));
|
assert_eq!(humanbytes(MEBI - 1), format!("1024.00 K"));
|
||||||
assert_eq!(humanbytes(MEBI), format!("1.00 M"));
|
assert_eq!(humanbytes(MEBI), format!("1.00 M"));
|
||||||
assert_eq!(humanbytes(MEBI+1), format!("1.00 M"));
|
assert_eq!(humanbytes(MEBI + 1), format!("1.00 M"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(GIBI-1), format!("1024.00 M"));
|
assert_eq!(humanbytes(GIBI - 1), format!("1024.00 M"));
|
||||||
assert_eq!(humanbytes(GIBI), format!("1.00 G"));
|
assert_eq!(humanbytes(GIBI), format!("1.00 G"));
|
||||||
assert_eq!(humanbytes(GIBI+1), format!("1.00 G"));
|
assert_eq!(humanbytes(GIBI + 1), format!("1.00 G"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(TEBI-1), format!("1024.00 G"));
|
assert_eq!(humanbytes(TEBI - 1), format!("1024.00 G"));
|
||||||
assert_eq!(humanbytes(TEBI), format!("1.00 T"));
|
assert_eq!(humanbytes(TEBI), format!("1.00 T"));
|
||||||
assert_eq!(humanbytes(TEBI+1), format!("1.00 T"));
|
assert_eq!(humanbytes(TEBI + 1), format!("1.00 T"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(PEBI-1), format!("1024.00 T"));
|
assert_eq!(humanbytes(PEBI - 1), format!("1024.00 T"));
|
||||||
assert_eq!(humanbytes(PEBI), format!("1.00 P"));
|
assert_eq!(humanbytes(PEBI), format!("1.00 P"));
|
||||||
assert_eq!(humanbytes(PEBI+1), format!("1.00 P"));
|
assert_eq!(humanbytes(PEBI + 1), format!("1.00 P"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(EXBI-1), format!("1024.00 P"));
|
assert_eq!(humanbytes(EXBI - 1), format!("1024.00 P"));
|
||||||
assert_eq!(humanbytes(EXBI), format!("1.00 E"));
|
assert_eq!(humanbytes(EXBI), format!("1.00 E"));
|
||||||
assert_eq!(humanbytes(EXBI+1), format!("1.00 E"));
|
assert_eq!(humanbytes(EXBI + 1), format!("1.00 E"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(ZEBI-1), format!("1024.00 E"));
|
assert_eq!(humanbytes(ZEBI - 1), format!("1024.00 E"));
|
||||||
assert_eq!(humanbytes(ZEBI), format!("1.00 Z"));
|
assert_eq!(humanbytes(ZEBI), format!("1.00 Z"));
|
||||||
assert_eq!(humanbytes(ZEBI+1), format!("1.00 Z"));
|
assert_eq!(humanbytes(ZEBI + 1), format!("1.00 Z"));
|
||||||
|
|
||||||
assert_eq!(humanbytes(YOBI-1), format!("1024.00 Z"));
|
assert_eq!(humanbytes(YOBI - 1), format!("1024.00 Z"));
|
||||||
assert_eq!(humanbytes(YOBI), format!("1.00 Y"));
|
assert_eq!(humanbytes(YOBI), format!("1.00 Y"));
|
||||||
assert_eq!(humanbytes(YOBI+1), format!("1.00 Y"));
|
assert_eq!(humanbytes(YOBI + 1), format!("1.00 Y"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
#![warn(clippy::pedantic)]
|
#![warn(clippy::pedantic)]
|
||||||
|
|
||||||
//// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
|
//// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
|
||||||
use std::fmt::Display;
|
|
||||||
pub use num_traits::PrimInt;
|
pub use num_traits::PrimInt;
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[allow(unused_imports)] // we possibly want to use all log levels
|
#[allow(unused_imports)] // we possibly want to use all log levels
|
||||||
use libpt_log::*;
|
use libpt_log::*;
|
||||||
|
@ -48,7 +48,7 @@ pub enum Operator {
|
||||||
/// Mathmatical modulo, finite field arithmetic
|
/// Mathmatical modulo, finite field arithmetic
|
||||||
Modulo,
|
Modulo,
|
||||||
/// Any function, seel [`Function`]
|
/// Any function, seel [`Function`]
|
||||||
Function(Function)
|
Function(Function),
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -82,7 +82,7 @@ pub enum Function {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// The term has bad syntax
|
/// The term has bad syntax
|
||||||
SyntaxError(String)
|
SyntaxError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -106,7 +106,7 @@ pub enum NumVal {
|
||||||
/// Value can be negative
|
/// Value can be negative
|
||||||
Unsigned(u128),
|
Unsigned(u128),
|
||||||
/// Value is not an integer
|
/// Value is not an integer
|
||||||
Float(f64)
|
Float(f64),
|
||||||
}
|
}
|
||||||
|
|
||||||
//// STRUCTS ///////////////////////////////////////////////////////////////////////////////////////
|
//// STRUCTS ///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -114,28 +114,27 @@ pub enum NumVal {
|
||||||
///
|
///
|
||||||
/// currently not implemented
|
/// currently not implemented
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VarVal {
|
pub struct VarVal {}
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Represents a Value with a complex number,
|
/// Represents a Value with a complex number,
|
||||||
///
|
///
|
||||||
/// currently not implemented
|
/// currently not implemented
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ComplVal {
|
pub struct ComplVal {}
|
||||||
}
|
|
||||||
|
|
||||||
//// IMPLEMENTATION ////////////////////////////////////////////////////////////////////////////////
|
//// IMPLEMENTATION ////////////////////////////////////////////////////////////////////////////////
|
||||||
impl<T: num_traits::PrimInt> From<T> for NumVal where
|
impl<T: num_traits::PrimInt> From<T> for NumVal
|
||||||
|
where
|
||||||
u128: TryFrom<T>,
|
u128: TryFrom<T>,
|
||||||
u128: TryFrom<T> {
|
u128: TryFrom<T>,
|
||||||
|
{
|
||||||
fn from(value: T) -> Self {
|
fn from(value: T) -> Self {
|
||||||
if T::min_value().is_zero() {
|
if T::min_value().is_zero() {
|
||||||
// unsigned data types
|
// unsigned data types
|
||||||
// `u128` is the largest unsigned datatype, any other type will fit.
|
// `u128` is the largest unsigned datatype, any other type will fit.
|
||||||
NumVal::Unsigned(value.to_u128().unwrap())
|
NumVal::Unsigned(value.to_u128().unwrap())
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// signed data types
|
// signed data types
|
||||||
// `i128` is the largest unsigned datatype, any other type will fit.
|
// `i128` is the largest unsigned datatype, any other type will fit.
|
||||||
NumVal::Signed(value.to_i128().unwrap())
|
NumVal::Signed(value.to_i128().unwrap())
|
||||||
|
@ -155,9 +154,11 @@ impl Display for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
impl<T: PrimInt> From<T> for Value where
|
impl<T: PrimInt> From<T> for Value
|
||||||
|
where
|
||||||
u128: TryFrom<T>,
|
u128: TryFrom<T>,
|
||||||
u128: TryFrom<T> {
|
u128: TryFrom<T>,
|
||||||
|
{
|
||||||
fn from(value: T) -> Self {
|
fn from(value: T) -> Self {
|
||||||
NumVal::from(value).into()
|
NumVal::from(value).into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub struct Calculator;
|
||||||
impl Calculator {
|
impl Calculator {
|
||||||
/// Do a single calculation without doing anything else
|
/// Do a single calculation without doing anything else
|
||||||
pub fn oneshot(t: String) -> Result<Value> {
|
pub fn oneshot(t: String) -> Result<Value> {
|
||||||
trace!(orig=t, "parsing original string to Term");
|
trace!(orig = t, "parsing original string to Term");
|
||||||
let t = Term::new(t)?;
|
let t = Term::new(t)?;
|
||||||
trace!("term has been parsed, starting Calculation");
|
trace!("term has been parsed, starting Calculation");
|
||||||
debug!("parsed term: {t:#?}");
|
debug!("parsed term: {t:#?}");
|
||||||
|
@ -73,9 +73,9 @@ impl Calculator {
|
||||||
if t.result.is_none() {
|
if t.result.is_none() {
|
||||||
let reason = format!("Term was processed but no result was assigned.");
|
let reason = format!("Term was processed but no result was assigned.");
|
||||||
// FIXME: unfitting error type
|
// FIXME: unfitting error type
|
||||||
return Err(Error::SyntaxError(reason))
|
return Err(Error::SyntaxError(reason));
|
||||||
}
|
}
|
||||||
return t.result.unwrap()
|
return t.result.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,10 @@
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
//// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
|
//// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
|
||||||
pub use super::{Error, Result, Value, base::{self, *}};
|
pub use super::{
|
||||||
|
base::{self, *},
|
||||||
|
Error, Result, Value,
|
||||||
|
};
|
||||||
#[allow(unused_imports)] // we possibly want to use all log levels
|
#[allow(unused_imports)] // we possibly want to use all log levels
|
||||||
use libpt_log::*;
|
use libpt_log::*;
|
||||||
#[allow(unused_imports)] // import more complex math stuff from there
|
#[allow(unused_imports)] // import more complex math stuff from there
|
||||||
|
@ -73,7 +76,7 @@ pub struct Term {
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
#[allow(unused)] // tmp
|
#[allow(unused)] // tmp
|
||||||
operator_stack: Vec<Operator>,
|
operator_stack: Vec<Operator>,
|
||||||
output_queue: VecDeque<Token>
|
output_queue: VecDeque<Token>,
|
||||||
}
|
}
|
||||||
|
|
||||||
//// IMPLEMENTATION ////////////////////////////////////////////////////////////////////////////////
|
//// IMPLEMENTATION ////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -82,15 +85,13 @@ impl Term {
|
||||||
///
|
///
|
||||||
/// Invalid terms will result in an [`Err`].
|
/// Invalid terms will result in an [`Err`].
|
||||||
pub fn new(orig: String) -> Result<Term> {
|
pub fn new(orig: String) -> Result<Term> {
|
||||||
return Ok(
|
return Ok(Term {
|
||||||
Term {
|
|
||||||
original: orig,
|
original: orig,
|
||||||
text: String::new(), // will be initialized in `prepare()`
|
text: String::new(), // will be initialized in `prepare()`
|
||||||
result: None,
|
result: None,
|
||||||
operator_stack: Vec::new(),
|
operator_stack: Vec::new(),
|
||||||
output_queue: VecDeque::new()
|
output_queue: VecDeque::new(),
|
||||||
}
|
});
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepare the term for the processing.
|
/// Prepare the term for the processing.
|
||||||
|
@ -144,8 +145,10 @@ impl Term {
|
||||||
// - '学' alphanumeric
|
// - '学' alphanumeric
|
||||||
// - '+' not alphanumeric
|
// - '+' not alphanumeric
|
||||||
for c in s.chars() {
|
for c in s.chars() {
|
||||||
#[cfg(debug_assertions)] {
|
#[cfg(debug_assertions)]
|
||||||
debug!("filter checks for '{c}':
|
{
|
||||||
|
debug!(
|
||||||
|
"filter checks for '{c}':
|
||||||
alphanumeric: {}
|
alphanumeric: {}
|
||||||
allowed special: {}
|
allowed special: {}
|
||||||
EXCEPT IF
|
EXCEPT IF
|
||||||
|
@ -156,16 +159,7 @@ impl Term {
|
||||||
c.is_ascii_control(),
|
c.is_ascii_control(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if
|
if (!c.is_alphanumeric() || !Self::is_allowed_special_c(&c)) && (c.is_ascii_control()) {
|
||||||
(
|
|
||||||
!c.is_alphanumeric() ||
|
|
||||||
!Self::is_allowed_special_c(&c)
|
|
||||||
)
|
|
||||||
&&
|
|
||||||
(
|
|
||||||
c.is_ascii_control()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// TODO: allow any unicode char to be a variable
|
// TODO: allow any unicode char to be a variable
|
||||||
let reason = format!("'{c}' is not a valid character, only alphanumeric, punctuation, operators are allowed.");
|
let reason = format!("'{c}' is not a valid character, only alphanumeric, punctuation, operators are allowed.");
|
||||||
warn!(reason);
|
warn!(reason);
|
||||||
|
@ -181,14 +175,14 @@ impl Term {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(filtered)
|
return Ok(filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// check if we should ignore this character
|
/// check if we should ignore this character
|
||||||
fn is_ignore(c: &char) -> bool {
|
fn is_ignore(c: &char) -> bool {
|
||||||
match *c {
|
match *c {
|
||||||
' ' => true,
|
' ' => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,21 +190,22 @@ impl Term {
|
||||||
fn is_allowed_special_c(c: &char) -> bool {
|
fn is_allowed_special_c(c: &char) -> bool {
|
||||||
match *c {
|
match *c {
|
||||||
'+' | '-' | '*' | '/' | '%' => true,
|
'+' | '-' | '*' | '/' | '%' => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Helper methods for Tokens
|
/// Helper methods for Tokens
|
||||||
impl Token { }
|
impl Token {}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
impl<T> From<T> for Token where
|
impl<T> From<T> for Token
|
||||||
|
where
|
||||||
T: Into<Value>,
|
T: Into<Value>,
|
||||||
T: PrimInt,
|
T: PrimInt,
|
||||||
u128: TryFrom<T>
|
u128: TryFrom<T>,
|
||||||
{
|
{
|
||||||
fn from(value: T) -> Self {
|
fn from(value: T) -> Self {
|
||||||
Token::Value(base::Value::from(value))
|
Token::Value(base::Value::from(value))
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,9 @@
|
||||||
// we want docs
|
// we want docs
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(rustdoc::missing_crate_level_docs)]
|
#![warn(rustdoc::missing_crate_level_docs)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// we want Debug everywhere.
|
// we want Debug everywhere.
|
||||||
#![warn(missing_debug_implementations)]
|
#![warn(missing_debug_implementations)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// enable clippy's extra lints, the pedantic version
|
// enable clippy's extra lints, the pedantic version
|
||||||
#![warn(clippy::pedantic)]
|
#![warn(clippy::pedantic)]
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
// we want docs
|
// we want docs
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(rustdoc::missing_crate_level_docs)]
|
#![warn(rustdoc::missing_crate_level_docs)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// we want Debug everywhere.
|
// we want Debug everywhere.
|
||||||
#![warn(missing_debug_implementations)]
|
#![warn(missing_debug_implementations)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// enable clippy's extra lints, the pedantic version
|
// enable clippy's extra lints, the pedantic version
|
||||||
#![warn(clippy::pedantic)]
|
#![warn(clippy::pedantic)]
|
||||||
|
|
|
@ -90,4 +90,3 @@ impl std::fmt::Display for Error {
|
||||||
//// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////
|
//// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//// PRIVATE FUNCTIONS /////////////////////////////////////////////////////////////////////////////
|
//// PRIVATE FUNCTIONS /////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ use error::*;
|
||||||
|
|
||||||
pub use tracing::{debug, error, info, trace, warn, Level};
|
pub use tracing::{debug, error, info, trace, warn, Level};
|
||||||
use tracing_appender;
|
use tracing_appender;
|
||||||
use tracing_subscriber::{prelude::*, fmt::format::FmtSpan};
|
use tracing_subscriber::{fmt::format::FmtSpan, prelude::*};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
//// CONSTANTS /////////////////////////////////////////////////////////////////////////////////////
|
//// CONSTANTS /////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -254,4 +254,3 @@ impl fmt::Debug for Logger {
|
||||||
//// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////
|
//// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//// PRIVATE FUNCTIONS /////////////////////////////////////////////////////////////////////////////
|
//// PRIVATE FUNCTIONS /////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,9 @@
|
||||||
// we want docs
|
// we want docs
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(rustdoc::missing_crate_level_docs)]
|
#![warn(rustdoc::missing_crate_level_docs)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// we want Debug everywhere.
|
// we want Debug everywhere.
|
||||||
#![warn(missing_debug_implementations)]
|
#![warn(missing_debug_implementations)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// enable clippy's extra lints, the pedantic version
|
// enable clippy's extra lints, the pedantic version
|
||||||
#![warn(clippy::pedantic)]
|
#![warn(clippy::pedantic)]
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
// we want docs
|
// we want docs
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![warn(rustdoc::missing_crate_level_docs)]
|
#![warn(rustdoc::missing_crate_level_docs)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// we want Debug everywhere.
|
// we want Debug everywhere.
|
||||||
#![warn(missing_debug_implementations)]
|
#![warn(missing_debug_implementations)]
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// enable clippy's extra lints, the pedantic version
|
// enable clippy's extra lints, the pedantic version
|
||||||
#![warn(clippy::pedantic)]
|
#![warn(clippy::pedantic)]
|
||||||
|
|
|
@ -188,7 +188,11 @@ pub fn continuous_uptime_monitor(
|
||||||
let mut last_was_up: bool = true;
|
let mut last_was_up: bool = true;
|
||||||
let mut last_ratio: u8 = status.success_ratio;
|
let mut last_ratio: u8 = status.success_ratio;
|
||||||
loop {
|
loop {
|
||||||
trace!(?status, ?last_was_up, "loop iteration for continuous uptime monitor");
|
trace!(
|
||||||
|
?status,
|
||||||
|
?last_was_up,
|
||||||
|
"loop iteration for continuous uptime monitor"
|
||||||
|
);
|
||||||
if !status.success {
|
if !status.success {
|
||||||
if last_was_up {
|
if last_was_up {
|
||||||
trace!("displaying status");
|
trace!("displaying status");
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// FIXME: Using a local dependency does not work with maturin as it seems?
|
// FIXME: Using a local dependency does not work with maturin as it seems?
|
||||||
use libpt::{
|
use libpt::log::*;
|
||||||
log::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
//! `pt` is a project consisting of multiple smaller crates, all bundled together in this
|
//! `pt` is a project consisting of multiple smaller crates, all bundled together in this
|
||||||
//! "main crate". Most crates will only show up if you activate their feature.
|
//! "main crate". Most crates will only show up if you activate their feature.
|
||||||
|
|
||||||
#[cfg(feature = "core")]
|
|
||||||
pub use libpt_core as core;
|
|
||||||
#[cfg(feature = "bintols")]
|
#[cfg(feature = "bintols")]
|
||||||
pub use libpt_bintols as bintols;
|
pub use libpt_bintols as bintols;
|
||||||
|
#[cfg(feature = "ccc")]
|
||||||
|
pub use libpt_ccc as ccc;
|
||||||
|
#[cfg(feature = "core")]
|
||||||
|
pub use libpt_core as core;
|
||||||
#[cfg(feature = "hedu")]
|
#[cfg(feature = "hedu")]
|
||||||
pub use libpt_hedu as hedu;
|
pub use libpt_hedu as hedu;
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
|
@ -18,5 +20,3 @@ pub use libpt_log as log;
|
||||||
pub use libpt_math as math;
|
pub use libpt_math as math;
|
||||||
#[cfg(feature = "net")]
|
#[cfg(feature = "net")]
|
||||||
pub use libpt_net as net;
|
pub use libpt_net as net;
|
||||||
#[cfg(feature = "ccc")]
|
|
||||||
pub use libpt_ccc as ccc;
|
|
||||||
|
|
Reference in New Issue