diff --git a/examples/actix-app/Cargo.toml b/examples/actix-app/Cargo.toml index 990632ab..35336250 100644 --- a/examples/actix-app/Cargo.toml +++ b/examples/actix-app/Cargo.toml @@ -9,7 +9,7 @@ publish = false [dependencies] actix-web = "4.3.1" fluent = "0.16.0" -serde_json = "1.0.99" +serde_json = "1.0.100" tracing = "0.1.37" [dependencies.serde] diff --git a/examples/axum-app/Cargo.toml b/examples/axum-app/Cargo.toml index 13ba4ee5..f638d6f2 100644 --- a/examples/axum-app/Cargo.toml +++ b/examples/axum-app/Cargo.toml @@ -9,7 +9,7 @@ publish = false [dependencies] axum = "0.6.18" fluent = "0.16.0" -serde_json = "1.0.99" +serde_json = "1.0.100" tracing = "0.1.37" [dependencies.serde] diff --git a/zino-core/Cargo.toml b/zino-core/Cargo.toml index c7261f78..1a64056e 100644 --- a/zino-core/Cargo.toml +++ b/zino-core/Cargo.toml @@ -155,7 +155,7 @@ version = "1.0.164" features = ["derive"] [dependencies.serde_json] -version = "1.0.99" +version = "1.0.100" features = ["raw_value"] [dependencies.sqlx] diff --git a/zino-core/src/chatbot/chatbot_openai.rs b/zino-core/src/chatbot/chatbot_openai.rs index c04f1b6f..3f324bf4 100644 --- a/zino-core/src/chatbot/chatbot_openai.rs +++ b/zino-core/src/chatbot/chatbot_openai.rs @@ -1,4 +1,4 @@ -use super::{chatbot::ChatbotClient::OpenAi, Chatbot, ChatbotService}; +use super::{client::ChatbotClient::OpenAi, Chatbot, ChatbotService}; use crate::{ application::http_client, error::Error, diff --git a/zino-core/src/chatbot/chatbot.rs b/zino-core/src/chatbot/client.rs similarity index 97% rename from zino-core/src/chatbot/chatbot.rs rename to zino-core/src/chatbot/client.rs index 180e57a9..f166a5bb 100644 --- a/zino-core/src/chatbot/chatbot.rs +++ b/zino-core/src/chatbot/client.rs @@ -47,7 +47,7 @@ impl Chatbot { "openai" => OpenAiChatCompletion::try_new_chatbot(config), _ => { let message = format!("chatbot service `{service}` is unsupported"); - return Err(Error::new(message)); + Err(Error::new(message)) } } } diff --git a/zino-core/src/chatbot/mod.rs b/zino-core/src/chatbot/mod.rs index 4531fcd6..5f407b65 100644 --- a/zino-core/src/chatbot/mod.rs +++ b/zino-core/src/chatbot/mod.rs @@ -11,13 +11,13 @@ use crate::{error::Error, extension::TomlTableExt, state::State, Map}; use std::sync::LazyLock; use toml::Table; -mod chatbot; +mod client; /// Supported chatbot services. #[cfg(feature = "chatbot-openai")] mod chatbot_openai; -pub use chatbot::Chatbot; +pub use client::Chatbot; #[cfg(feature = "chatbot-openai")] use chatbot_openai::OpenAiChatCompletion; diff --git a/zino-core/src/connector/connector_arrow/arrow_array.rs b/zino-core/src/connector/connector_arrow/arrow_array.rs index cbbf2c9a..03905bb4 100644 --- a/zino-core/src/connector/connector_arrow/arrow_array.rs +++ b/zino-core/src/connector/connector_arrow/arrow_array.rs @@ -266,7 +266,7 @@ impl ArrowArrayExt for dyn Array { let position = dictionary_array.lookup_key(value).ok_or_else(|| { Error::new(format!("value `{value}` is not in the dictionary")) })?; - AvroValue::Enum(position.try_into()?, value.to_owned()) + AvroValue::Enum(position, value.to_owned()) } data_type => { let message = format!("cannot convert the `{data_type}` value to an Avro value"); diff --git a/zino-core/src/connector/connector_arrow/arrow_schema.rs b/zino-core/src/connector/connector_arrow/arrow_schema.rs index d60e6f94..576b63d9 100644 --- a/zino-core/src/connector/connector_arrow/arrow_schema.rs +++ b/zino-core/src/connector/connector_arrow/arrow_schema.rs @@ -41,7 +41,7 @@ impl ArrowSchemaExt for Schema { TomlValue::Array(array) => { let length = array.len(); if length == 1 && let Some(TomlValue::String(value_type)) = array.first() { - let item_data_type = parse_arrow_data_type(&value_type)?; + let item_data_type = parse_arrow_data_type(value_type)?; let field = Field::new("item", item_data_type, true); DataType::List(Arc::new(field)) } else if length >= 2 { diff --git a/zino-core/src/connector/connector_arrow/data_frame.rs b/zino-core/src/connector/connector_arrow/data_frame.rs index 820a304b..9a1ca80e 100644 --- a/zino-core/src/connector/connector_arrow/data_frame.rs +++ b/zino-core/src/connector/connector_arrow/data_frame.rs @@ -43,9 +43,8 @@ impl DataFrameExecutor for DataFrame { for field in &batch.schema().fields { let field_name = field.name().as_str(); if let Some(array) = batch.column_by_name(field_name) { - for i in 0..num_rows { - let record = &mut records[i]; - let value = array.parse_avro_value(i)?; + for (index, record) in records.iter_mut().enumerate() { + let value = array.parse_avro_value(index)?; record.push((field_name.to_owned(), value)); } } @@ -67,9 +66,8 @@ impl DataFrameExecutor for DataFrame { for field in &batch.schema().fields { let field_name = field.name().as_str(); if let Some(array) = batch.column_by_name(field_name) { - for i in 0..num_rows { - let map = &mut data[i]; - let value = array.parse_json_value(i)?; + for (index, map) in data.iter_mut().enumerate() { + let value = array.parse_json_value(index)?; map.insert(field_name.to_owned(), value); } } diff --git a/zino-core/src/connector/data_source.rs b/zino-core/src/connector/data_source.rs index 49724554..6d3edfce 100644 --- a/zino-core/src/connector/data_source.rs +++ b/zino-core/src/connector/data_source.rs @@ -103,7 +103,7 @@ impl DataSource { /// Returns the protocol. #[inline] pub fn protocol(&self) -> &'static str { - &self.protocol + self.protocol } /// Returns the data source type. diff --git a/zino-core/src/connector/mod.rs b/zino-core/src/connector/mod.rs index 21801fe5..84878da3 100644 --- a/zino-core/src/connector/mod.rs +++ b/zino-core/src/connector/mod.rs @@ -80,7 +80,7 @@ pub trait Connector { let data = self.query(query, params).await?; let value = data .into_iter() - .map(|record| AvroValue::Record(record)) + .map(AvroValue::Record) .collect::>(); apache_avro::from_value(&AvroValue::Array(value)).map_err(|err| err.into()) } diff --git a/zino-core/src/database/mysql.rs b/zino-core/src/database/mysql.rs index f461df9d..05b9ca9d 100644 --- a/zino-core/src/database/mysql.rs +++ b/zino-core/src/database/mysql.rs @@ -78,10 +78,7 @@ impl<'c> EncodeColumn for Column<'c> { .collect::>(); format!(r#"json_array({})"#, values.join(",")).into() } - JsonValue::Object(_) => { - let value = Query::escape_string(value); - format!("{value}").into() - } + JsonValue::Object(_) => Query::escape_string(value).into(), } } else if self.default_value().is_some() { "DEFAULT".into() @@ -140,7 +137,7 @@ impl<'c> EncodeColumn for Column<'c> { "midnight" => "'00:00:00'".into(), _ => Query::escape_string(value).into(), }, - "Vec" => format!("'value'").into(), + "Vec" => format!("'{value}'").into(), "Vec" | "Vec" => { if value.contains(',') { let values = value @@ -153,10 +150,7 @@ impl<'c> EncodeColumn for Column<'c> { format!(r#"json_array({value})"#).into() } } - "Map" => { - let value = Query::escape_string(value); - format!("{value}").into() - } + "Map" => Query::escape_string(value).into(), _ => "NULL".into(), } } @@ -365,7 +359,7 @@ impl DecodeRow for Map { "DOUBLE" => decode_column::(field, raw_value)?.into(), "NUMERIC" => { let value = decode_column::(field, raw_value)?; - serde_json::to_value(&value)? + serde_json::to_value(value)? } "TEXT" | "VARCHAR" | "CHAR" => { decode_column::(field, raw_value)?.into() diff --git a/zino-core/src/encoding/base64.rs b/zino-core/src/encoding/base64.rs index 1aca50b2..9f4719df 100644 --- a/zino-core/src/encoding/base64.rs +++ b/zino-core/src/encoding/base64.rs @@ -18,6 +18,6 @@ pub(crate) fn decode(data: impl AsRef<[u8]>) -> Result, DecodeError> { pub(crate) fn encode_data_url(data: impl AsRef<[u8]>) -> String { let bytes = data.as_ref(); let mut data = String::with_capacity(bytes.len() * 3 / 4); - base64::engine::general_purpose::STANDARD.encode_string(&bytes, &mut data); + base64::engine::general_purpose::STANDARD.encode_string(bytes, &mut data); format!("data:text/plain;base64,{data}") } diff --git a/zino/Cargo.toml b/zino/Cargo.toml index 0b61289a..e211c0c8 100644 --- a/zino/Cargo.toml +++ b/zino/Cargo.toml @@ -44,7 +44,7 @@ futures = "0.3.28" hyper = "0.14.27" parking_lot = "0.12.1" serde = "1.0.163" -serde_json = "1.0.99" +serde_json = "1.0.100" toml = "0.7.3" tracing = "0.1.37"