Skip to content

Commit

Permalink
cargo fmt & 1.4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyigumnov committed Nov 7, 2024
1 parent 7b06d80 commit 2ef25a5
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
Cargo.toml
```toml
[dependencies]
shiva = { version = "1.4.8", features = ["html", "markdown", "text", "pdf", "json",
shiva = { version = "1.4.9", features = ["html", "markdown", "text", "pdf", "json",
"csv", "rtf", "docx", "xml", "xls", "xlsx", "ods", "typst"] }
```

Expand Down
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shiva"
version = "1.4.8"
version = "1.4.9"
edition = "2021"
authors = ["Evgeny Igumnov <[email protected]>"]
repository = "https://github.com/igumnoff/shiva"
Expand Down
11 changes: 4 additions & 7 deletions lib/src/core.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use bytes::Bytes;
use log::info;
#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use std::{collections::HashMap, fmt::Debug};
use strum::{Display, EnumCount, EnumString, IntoStaticStr, VariantArray};
use thiserror::Error;
use wasm_bindgen::prelude::wasm_bindgen;
use log::info;

#[cfg(feature = "csv")]
use crate::csv;
Expand Down Expand Up @@ -805,23 +805,20 @@ impl DocumentType {
#[cfg(test)]
pub mod tests {
use super::*;
use env_logger::Env;
use std::str::FromStr;
use std::sync::Once;
use env_logger::Env;

static INIT: Once = Once::new();

pub fn init_logger() {
INIT.call_once(|| {
env_logger::Builder::from_env(
Env::default()
.default_filter_or("info"))
env_logger::Builder::from_env(Env::default().default_filter_or("info"))
.format_timestamp(None)
.init();
});
}


const VARIANTS: &[DocumentType] = &[
DocumentType::HTML,
DocumentType::Markdown,
Expand Down Expand Up @@ -948,4 +945,4 @@ pub mod tests {
}
}

pub use bytes;
pub use bytes;
2 changes: 1 addition & 1 deletion lib/src/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::core::{
Element::{Table, Text},
TableCell, TableHeader, TableRow, TransformerTrait,
};
use log::info;
use bytes::Bytes;
use log::info;
pub struct Transformer;

#[allow(unused)]
Expand Down
4 changes: 2 additions & 2 deletions lib/src/docx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use docx_rs::{
LevelText, NumberFormat, Numbering, NumberingId, Paragraph, ParagraphStyle, Pic, Run, RunChild,
SpecialIndentType, Start, TableRowChild,
};
use std::io::Cursor;
use log::{error, info, warn};
use std::io::Cursor;

pub struct Transformer;

Expand Down Expand Up @@ -519,11 +519,11 @@ impl TransformerTrait for Transformer {
#[cfg(test)]
mod tests {
use super::*;
use crate::core::tests::init_logger;
use crate::core::{disk_image_loader, TransformerWithImageLoaderSaverTrait};
use crate::{docx, markdown};
use bytes::Bytes;
use log::info;
use crate::core::tests::init_logger;

#[test]
fn test() -> anyhow::Result<()> {
Expand Down
13 changes: 6 additions & 7 deletions lib/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,10 @@ fn generate_html_for_element(
}
Hyperlink {
title, url, alt, ..
} => {
Ok(format!(
} => Ok(format!(
"<a href=\"{}\" title=\"{}\">{}</a>",
url, alt, title
))},
)),
_ => Ok("".to_string()),
}
}
Expand Down Expand Up @@ -445,13 +444,13 @@ fn retrieve_deep_text(node: NodeRef<Node>, tag_name: &str) -> String {

#[cfg(test)]
mod tests {
use log::debug;
use log::info;
use crate::core::tests::init_logger;
use crate::core::*;
use crate::html::*;
use crate::markdown;
use crate::core::tests::init_logger;

use log::debug;
use log::info;

#[test]
fn test_image_loader_saver() -> anyhow::Result<()> {
init_logger();
Expand Down
2 changes: 1 addition & 1 deletion lib/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,9 @@ fn parse_list_item(value: &Value) -> anyhow::Result<ListItem> {
mod tests {
use log::{debug, info};

use crate::core::tests::init_logger;
use crate::core::{disk_image_loader, TransformerWithImageLoaderSaverTrait};
use crate::json::TransformerTrait;
use crate::core::tests::init_logger;

#[test]
fn test() -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,10 @@ mod tests {
use log::info;
use serde_xml_rs::to_string;

use crate::core::tests::init_logger;
use crate::core::*;
use crate::html;
use crate::markdown::*;
use crate::core::tests::init_logger;

#[test]
fn test() -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ impl TransformerTrait for Transformer {

#[cfg(test)]
mod tests {
use crate::core::tests::init_logger;
use crate::ods::*;
use anyhow::Ok;
use bytes::Bytes;
use log::{debug, info};
use std::fs::File;
use std::io::Read;
use crate::core::tests::init_logger;

#[test]
fn test_parse() -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ impl TransformerTrait for Transformer {
mod tests {
use log::{debug, info};

use crate::core::tests::init_logger;
use crate::core::Element::Header;
use crate::core::*;
use crate::text::*;
use crate::core::tests::init_logger;

#[test]
fn test() -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/xls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl TransformerTrait for Transformer {

#[cfg(test)]
mod tests {
use crate::core::tests::init_logger;
use crate::text;
use crate::xls::*;
use anyhow::Ok;
Expand All @@ -84,7 +85,6 @@ mod tests {
use log::info;
use std::fs::File;
use std::io::Read;
use crate::core::tests::init_logger;

#[test]
fn test_parse() -> anyhow::Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/xlsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ impl TransformerTrait for Transformer {

#[cfg(test)]
mod tests {
use crate::core::tests::init_logger;
use crate::xlsx::*;
use anyhow::Ok;
use bytes::Bytes;
use log::{info, debug};
use log::{debug, info};
use std::fs::File;
use std::io::Read;
use crate::core::tests::init_logger;

#[test]
fn test_parse() -> anyhow::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,13 +1004,13 @@ impl TransformerTrait for Transformer {

#[cfg(test)]
mod tests {
use crate::core::tests::init_logger;
use crate::markdown;
use crate::xml::*;
use bytes::Bytes;
use log::debug;
use std::fs::File;
use std::io::{Read, Write};
use crate::core::tests::init_logger;

#[test]
fn test_parse() -> anyhow::Result<()> {
Expand Down
7 changes: 3 additions & 4 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ mod web;
// multy thread
#[tokio::main]
async fn main() -> Result<()> {

env_logger::Builder::from_env(Env::default().default_filter_or("info"))
.format_timestamp(None)
.init();
.format_timestamp(None)
.init();

// Defining command line arguments
let matches = Command::new("Server")
Expand Down Expand Up @@ -91,13 +90,13 @@ mod tests {
use anyhow::anyhow;
use anyhow::Error;
use anyhow::Result;
use log::info;
use reqwest::multipart;
use reqwest::Body;
use std::fs;
use std::io::Cursor;
use std::io::Write;
use tokio::fs::File;
use log::info;

#[tokio::test]
async fn test_server() -> Result<()> {
Expand Down
6 changes: 5 additions & 1 deletion server/src/web/routes_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ async fn unpacking(mut field: Field<'_>) -> Result<StructUploadFile> {
.filter(|ext| !ext.trim().is_empty())
.map(String::from);

debug!("in ZIP {}.{}", file_name_in_archive.clone().unwrap(), file_extension_in_archive.clone().unwrap());
debug!(
"in ZIP {}.{}",
file_name_in_archive.clone().unwrap(),
file_extension_in_archive.clone().unwrap()
);

//checking the supported format
if let Some(ref ext) = file_extension_in_archive {
Expand Down

0 comments on commit 2ef25a5

Please sign in to comment.