♻️ Código revisado con cargo fmt/clippy
This commit is contained in:
parent
1d82c59c3d
commit
9bb429acf0
5 changed files with 34 additions and 34 deletions
|
|
@ -22,29 +22,7 @@ pub struct Application {
|
||||||
impl Application {
|
impl Application {
|
||||||
pub fn prepare(app: ModuleStaticRef) -> Result<Self, Error> {
|
pub fn prepare(app: ModuleStaticRef) -> Result<Self, Error> {
|
||||||
// Rótulo de presentación.
|
// Rótulo de presentación.
|
||||||
if config::SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
print_on_startup();
|
||||||
if let Some((term_width, _)) = term_size::dimensions() {
|
|
||||||
if term_width >= 80 {
|
|
||||||
let maxlen = (term_width / 10) - 2;
|
|
||||||
let mut app = config::SETTINGS.app.name.substring(0, maxlen).to_owned();
|
|
||||||
if config::SETTINGS.app.name.len() > maxlen {
|
|
||||||
app = format!("{}...", app);
|
|
||||||
}
|
|
||||||
println!(
|
|
||||||
"\n{} {}\n\n Powered by PageTop {}\n",
|
|
||||||
figfont::FIGFONT.convert(&app).unwrap(),
|
|
||||||
&config::SETTINGS.app.description,
|
|
||||||
env!("CARGO_PKG_VERSION")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!(
|
|
||||||
"\n{}\n{}\n\nPowered by PageTop {}\n",
|
|
||||||
&config::SETTINGS.app.name,
|
|
||||||
&config::SETTINGS.app.description,
|
|
||||||
env!("CARGO_PKG_VERSION")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicia registro de trazas y eventos.
|
// Inicia registro de trazas y eventos.
|
||||||
LazyStatic::force(&trace::TRACING);
|
LazyStatic::force(&trace::TRACING);
|
||||||
|
|
@ -91,6 +69,33 @@ impl Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_on_startup() {
|
||||||
|
if config::SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
||||||
|
if let Some((term_width, _)) = term_size::dimensions() {
|
||||||
|
if term_width >= 80 {
|
||||||
|
let maxlen = (term_width / 10) - 2;
|
||||||
|
let mut app = config::SETTINGS.app.name.substring(0, maxlen).to_owned();
|
||||||
|
if config::SETTINGS.app.name.len() > maxlen {
|
||||||
|
app = format!("{}...", app);
|
||||||
|
}
|
||||||
|
println!(
|
||||||
|
"\n{} {}\n\n Powered by PageTop {}\n",
|
||||||
|
figfont::FIGFONT.convert(&app).unwrap(),
|
||||||
|
&config::SETTINGS.app.description,
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!(
|
||||||
|
"\n{}\n{}\n\nPowered by PageTop {}\n",
|
||||||
|
&config::SETTINGS.app.name,
|
||||||
|
&config::SETTINGS.app.description,
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn service_not_found(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
|
async fn service_not_found(request: server::HttpRequest) -> ResultPage<Markup, FatalError> {
|
||||||
Err(FatalError::NotFound(request))
|
Err(FatalError::NotFound(request))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ impl<'de> de::MapAccess<'de> for MapAccess {
|
||||||
where
|
where
|
||||||
K: de::DeserializeSeed<'de>,
|
K: de::DeserializeSeed<'de>,
|
||||||
{
|
{
|
||||||
if let Some(&(ref key_s, _)) = self.elements.front() {
|
if let Some((key_s, _)) = self.elements.front() {
|
||||||
let key_de = Value::new(None, key_s as &str);
|
let key_de = Value::new(None, key_s as &str);
|
||||||
let key = de::DeserializeSeed::deserialize(seed, key_de)?;
|
let key = de::DeserializeSeed::deserialize(seed, key_de)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,7 @@ impl Expression {
|
||||||
let index = sindex_to_uindex(index, array.len());
|
let index = sindex_to_uindex(index, array.len());
|
||||||
|
|
||||||
if index >= array.len() {
|
if index >= array.len() {
|
||||||
array
|
array.resize(index + 1, Value::new(None, ValueKind::Nil));
|
||||||
.resize((index + 1) as usize, Value::new(None, ValueKind::Nil));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(&mut array[index])
|
Some(&mut array[index])
|
||||||
|
|
@ -156,7 +155,7 @@ impl Expression {
|
||||||
if let ValueKind::Array(ref mut array) = parent.kind {
|
if let ValueKind::Array(ref mut array) = parent.kind {
|
||||||
let uindex = sindex_to_uindex(index, array.len());
|
let uindex = sindex_to_uindex(index, array.len());
|
||||||
if uindex >= array.len() {
|
if uindex >= array.len() {
|
||||||
array.resize((uindex + 1) as usize, Value::new(None, ValueKind::Nil));
|
array.resize(uindex + 1, Value::new(None, ValueKind::Nil));
|
||||||
}
|
}
|
||||||
|
|
||||||
array[uindex] = value;
|
array[uindex] = value;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,9 @@ use std::fmt;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
/// Underlying kind of the configuration value.
|
/// Underlying kind of the configuration value.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Clone, Debug, Default, PartialEq)]
|
||||||
pub enum ValueKind {
|
pub enum ValueKind {
|
||||||
|
#[default]
|
||||||
Nil,
|
Nil,
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
Integer(i64),
|
Integer(i64),
|
||||||
|
|
@ -21,12 +22,6 @@ pub enum ValueKind {
|
||||||
pub type Array = Vec<Value>;
|
pub type Array = Vec<Value>;
|
||||||
pub type Table = HashMap<String, Value>;
|
pub type Table = HashMap<String, Value>;
|
||||||
|
|
||||||
impl Default for ValueKind {
|
|
||||||
fn default() -> Self {
|
|
||||||
ValueKind::Nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> From<Option<T>> for ValueKind
|
impl<T> From<Option<T>> for ValueKind
|
||||||
where
|
where
|
||||||
T: Into<ValueKind>,
|
T: Into<ValueKind>,
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,7 @@ pub trait MigratorTrait: Send {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::extra_unused_type_parameters)]
|
||||||
async fn exec_with_connection<'c, C, F, M>(db: C, f: F) -> Result<(), DbErr>
|
async fn exec_with_connection<'c, C, F, M>(db: C, f: F) -> Result<(), DbErr>
|
||||||
where
|
where
|
||||||
C: IntoSchemaManagerConnection<'c>,
|
C: IntoSchemaManagerConnection<'c>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue