clippy fix
This commit is contained in:
parent
f8e7eead5f
commit
0e949fae65
10 changed files with 52 additions and 72 deletions
|
@ -2,7 +2,7 @@ use crate::{Background, Slide, SlideBuilder, TextAlignment};
|
|||
|
||||
use super::{model::Model, service_items::ServiceTrait};
|
||||
use crisp::types::{Keyword, Value};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{query_as, SqliteConnection};
|
||||
use std::path::PathBuf;
|
||||
|
@ -114,7 +114,7 @@ pub async fn get_image_from_db(
|
|||
database_id: i32,
|
||||
db: &mut SqliteConnection,
|
||||
) -> Result<Image> {
|
||||
Ok(query_as!(Image, r#"SELECT title as "title!", file_path as "path!", id as "id: i32" from images where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()?)
|
||||
query_as!(Image, r#"SELECT title as "title!", file_path as "path!", id as "id: i32" from images where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::Slide;
|
|||
|
||||
use super::{
|
||||
images::Image,
|
||||
presentations::{PresKind, Presentation},
|
||||
presentations::Presentation,
|
||||
songs::Song,
|
||||
videos::Video,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::mem::replace;
|
||||
|
||||
use cosmic::{executor, iced::Executor, Task};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use cosmic::iced::Executor;
|
||||
use miette::{miette, Result};
|
||||
use sqlx::{Connection, SqliteConnection};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crisp::types::{Keyword, Value};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
prelude::FromRow, query, sqlite::SqliteRow, Row, SqliteConnection,
|
||||
|
@ -164,7 +164,7 @@ pub async fn get_presentation_from_db(
|
|||
db: &mut SqliteConnection,
|
||||
) -> Result<Presentation> {
|
||||
let row = query(r#"SELECT id as "id: i32", title, file_path as "path", html from presentations where id = $1"#).bind(database_id).fetch_one(db).await.into_diagnostic()?;
|
||||
Ok(Presentation::from_row(&row).into_diagnostic()?)
|
||||
Presentation::from_row(&row).into_diagnostic()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use miette::{miette, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::Display,
|
||||
path::{Path, PathBuf},
|
||||
str::FromStr,
|
||||
};
|
||||
use tracing::error;
|
||||
|
||||
|
@ -381,7 +379,7 @@ pub fn lisp_to_background(lisp: &Value) -> Background {
|
|||
panic!("Should always be there");
|
||||
};
|
||||
let mut home = home.to_string();
|
||||
home.push_str("/");
|
||||
home.push('/');
|
||||
|
||||
let s = s.replace("./", &home);
|
||||
match Background::try_from(s.as_str()) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use std::{collections::HashMap, fmt::Display, path::PathBuf};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use cosmic::{executor, iced::Executor};
|
||||
use cosmic::iced::Executor;
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
query, query_as, sqlite::SqliteRow, FromRow, Row,
|
||||
query, sqlite::SqliteRow, FromRow, Row,
|
||||
SqliteConnection,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
|
@ -154,7 +154,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
.position(|v| v == &Value::Keyword(Keyword::from("id")))
|
||||
{
|
||||
let pos = key_pos + 1;
|
||||
list.get(pos).map(|c| i32::from(c)).unwrap_or_default()
|
||||
list.get(pos).map(i32::from).unwrap_or_default()
|
||||
} else {
|
||||
DEFAULT_SONG_ID
|
||||
};
|
||||
|
@ -164,7 +164,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
v == &Value::Keyword(Keyword::from("background"))
|
||||
}) {
|
||||
let pos = key_pos + 1;
|
||||
list.get(pos).map(|b| slide::lisp_to_background(b))
|
||||
list.get(pos).map(slide::lisp_to_background)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -174,7 +174,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
.position(|v| v == &Value::Keyword(Keyword::from("author")))
|
||||
{
|
||||
let pos = key_pos + 1;
|
||||
list.get(pos).map(|a| String::from(a))
|
||||
list.get(pos).map(String::from)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -204,7 +204,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
.position(|v| v == &Value::Keyword(Keyword::from("font")))
|
||||
{
|
||||
let pos = key_pos + 1;
|
||||
list.get(pos).map(|f| String::from(f))
|
||||
list.get(pos).map(String::from)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -213,7 +213,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
v == &Value::Keyword(Keyword::from("font-size"))
|
||||
}) {
|
||||
let pos = key_pos + 1;
|
||||
list.get(pos).map(|f| i32::from(f))
|
||||
list.get(pos).map(i32::from)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -224,7 +224,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
{
|
||||
let pos = key_pos + 1;
|
||||
list.get(pos)
|
||||
.map(|t| String::from(t))
|
||||
.map(String::from)
|
||||
.unwrap_or(String::from("song"))
|
||||
} else {
|
||||
String::from("song")
|
||||
|
@ -235,7 +235,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
v == &Value::Keyword(Keyword::from("text-alignment"))
|
||||
}) {
|
||||
let pos = key_pos + 1;
|
||||
list.get(pos).map(|t| TextAlignment::from(t))
|
||||
list.get(pos).map(TextAlignment::from)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -247,7 +247,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
let pos = key_pos + 1;
|
||||
list.get(pos).map(|v| match v {
|
||||
Value::List(vals) => vals
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|v| String::from(v).to_uppercase())
|
||||
.collect::<Vec<String>>(),
|
||||
_ => vec![],
|
||||
|
@ -256,8 +256,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
None
|
||||
};
|
||||
|
||||
let first_text_postiion = if let Some(pos) =
|
||||
list.iter().position(|v| match v {
|
||||
let first_text_postiion = list.iter().position(|v| match v {
|
||||
Value::List(inner) => {
|
||||
(match &inner[0] {
|
||||
Value::Symbol(Symbol(text)) => {
|
||||
|
@ -273,11 +272,7 @@ pub fn lisp_to_song(list: Vec<Value>) -> Song {
|
|||
})
|
||||
}
|
||||
_ => false,
|
||||
}) {
|
||||
pos
|
||||
} else {
|
||||
1
|
||||
};
|
||||
}).unwrap_or(1);
|
||||
|
||||
let lyric_elements = &list[first_text_postiion..];
|
||||
|
||||
|
@ -347,7 +342,7 @@ pub async fn get_song_from_db(
|
|||
db: &mut SqliteConnection,
|
||||
) -> Result<Song> {
|
||||
let row = query(r#"SELECT verse_order as "verse_order!", font_size as "font_size!: i32", background_type as "background_type!", horizontal_text_alignment as "horizontal_text_alignment!", vertical_text_alignment as "vertical_text_alignment!", title as "title!", font as "font!", background as "background!", lyrics as "lyrics!", ccli as "ccli!", author as "author!", audio as "audio!", id as "id: i32" from songs where id = $1"#).bind(index).fetch_one(db).await.into_diagnostic()?;
|
||||
Ok(Song::from_row(&row).into_diagnostic()?)
|
||||
Song::from_row(&row).into_diagnostic()
|
||||
}
|
||||
|
||||
impl Model<Song> {
|
||||
|
|
|
@ -3,9 +3,9 @@ use crate::{Background, SlideBuilder, TextAlignment};
|
|||
use super::{
|
||||
model::Model, service_items::ServiceTrait, slide::Slide,
|
||||
};
|
||||
use cosmic::{executor, iced::Executor};
|
||||
use cosmic::iced::Executor;
|
||||
use crisp::types::{Keyword, Value};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{query_as, SqliteConnection};
|
||||
use std::path::PathBuf;
|
||||
|
@ -83,7 +83,7 @@ impl From<&Value> for Video {
|
|||
let pos = loop_pos + 1;
|
||||
list.get(pos)
|
||||
.map(|l| {
|
||||
String::from(l) == "true".to_string()
|
||||
String::from(l) == *"true"
|
||||
})
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
|
@ -157,7 +157,7 @@ pub async fn get_video_from_db(
|
|||
database_id: i32,
|
||||
db: &mut SqliteConnection,
|
||||
) -> Result<Video> {
|
||||
Ok(query_as!(Video, r#"SELECT title as "title!", file_path as "path!", start_time as "start_time!: f32", end_time as "end_time!: f32", loop as "looping!", id as "id: i32" from videos where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()?)
|
||||
query_as!(Video, r#"SELECT title as "title!", file_path as "path!", start_time as "start_time!: f32", end_time as "end_time!: f32", loop as "looping!", id as "id: i32" from videos where id = ?"#, database_id).fetch_one(db).await.into_diagnostic()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue