This commit is contained in:
parent
a56ff6a022
commit
0d3f7180c9
4 changed files with 198 additions and 1100 deletions
|
|
@ -13,7 +13,7 @@ use sqlx::{
|
|||
pool::PoolConnection, query, query_as, Sqlite, SqliteConnection,
|
||||
SqlitePool,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use tracing::error;
|
||||
|
||||
#[derive(
|
||||
|
|
@ -25,6 +25,28 @@ pub struct Image {
|
|||
pub path: PathBuf,
|
||||
}
|
||||
|
||||
impl From<PathBuf> for Image {
|
||||
fn from(value: PathBuf) -> Self {
|
||||
let title = value
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
.to_str()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
Self {
|
||||
id: 0,
|
||||
title,
|
||||
path: value.canonicalize().unwrap_or(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Path> for Image {
|
||||
fn from(value: &Path) -> Self {
|
||||
Self::from(value.to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Image> for Value {
|
||||
fn from(value: &Image) -> Self {
|
||||
Self::List(vec![Self::Symbol(Symbol("image".into()))])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue