Skip to content

Commit 6a8e2a6

Browse files
committedAug 23, 2022
Appease pedantic clippy
1 parent bbcbfee commit 6a8e2a6

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed
 

‎backend/src/convert.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn unsupported_type_field(n: usize, type_: &Type, name: &str) -> data::Field {
3838
/// If the rows do not return the `MZ_TIMESTAMP` or `MZ_DIFF` columns
3939
/// they will be added automatically using the current timestamp and `None`
4040
/// as values respectively.
41-
pub fn rows_to_frame(rows: Vec<Row>) -> data::Frame {
41+
pub fn rows_to_frame(rows: &[Row]) -> data::Frame {
4242
let mut frame = data::Frame::new("tail");
4343
if rows.is_empty() {
4444
return frame;
@@ -51,14 +51,14 @@ pub fn rows_to_frame(rows: Vec<Row>) -> data::Frame {
5151
);
5252
if !has_mz_timestamp {
5353
let now = Utc::now();
54-
frame.add_field(iter::repeat(now).take(rows.len()).into_field(MZ_TIMESTAMP))
54+
frame.add_field(iter::repeat(now).take(rows.len()).into_field(MZ_TIMESTAMP));
5555
}
5656
if !has_mz_diff {
5757
frame.add_field(
5858
iter::repeat::<Option<i64>>(None)
5959
.take(rows.len())
6060
.into_opt_field(MZ_DIFF),
61-
)
61+
);
6262
}
6363

6464
for (i, column) in rows[0].columns().iter().enumerate() {
@@ -73,14 +73,14 @@ pub fn rows_to_frame(rows: Vec<Row>) -> data::Frame {
7373
.into_opt_field(name)
7474
} else {
7575
match column.type_() {
76-
&Type::CHAR => load_field::<i8>(&rows, i, name),
77-
&Type::INT2 => load_field::<i16>(&rows, i, name),
78-
&Type::INT4 => load_field::<i32>(&rows, i, name),
79-
&Type::INT8 => load_field::<i64>(&rows, i, name),
80-
&Type::FLOAT4 => load_field::<f32>(&rows, i, name),
81-
&Type::FLOAT8 => load_field::<f64>(&rows, i, name),
82-
&Type::OID => load_field::<u32>(&rows, i, name),
83-
&Type::TEXT | &Type::VARCHAR => load_field::<String>(&rows, i, name),
76+
&Type::CHAR => load_field::<i8>(rows, i, name),
77+
&Type::INT2 => load_field::<i16>(rows, i, name),
78+
&Type::INT4 => load_field::<i32>(rows, i, name),
79+
&Type::INT8 => load_field::<i64>(rows, i, name),
80+
&Type::FLOAT4 => load_field::<f32>(rows, i, name),
81+
&Type::FLOAT8 => load_field::<f64>(rows, i, name),
82+
&Type::OID => load_field::<u32>(rows, i, name),
83+
&Type::TEXT | &Type::VARCHAR => load_field::<String>(rows, i, name),
8484
&Type::JSON | &Type::JSONB => rows
8585
.iter()
8686
.map(|row| row.get::<_, serde_json::Value>(i).to_string())
@@ -89,9 +89,9 @@ pub fn rows_to_frame(rows: Vec<Row>) -> data::Frame {
8989
.iter()
9090
.map(|row| row.get::<_, Decimal>(i).to_i64())
9191
.into_opt_field(name),
92-
&Type::DATE => load_field::<NaiveDate>(&rows, i, name),
93-
&Type::TIMESTAMP => load_field::<NaiveDateTime>(&rows, i, name),
94-
&Type::TIMESTAMPTZ => load_field::<DateTime<Utc>>(&rows, i, name),
92+
&Type::DATE => load_field::<NaiveDate>(rows, i, name),
93+
&Type::TIMESTAMP => load_field::<NaiveDateTime>(rows, i, name),
94+
&Type::TIMESTAMPTZ => load_field::<DateTime<Utc>>(rows, i, name),
9595
other => unsupported_type_field(rows.len(), other, name),
9696
}
9797
};

‎backend/src/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async fn query_data_single(
4343
let q: Query = serde_json::from_value(query.json).map_err(Error::InvalidQuery)?;
4444
let target = q.as_tail()?;
4545
let rows = target.select_all(&client).await?;
46-
let mut frame = rows_to_frame(rows);
46+
let mut frame = rows_to_frame(&rows);
4747

4848
if let TailTarget::Select { statement } = target {
4949
let query_id = QueryId::from_statement(statement);

‎backend/src/stream.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use tracing::debug;
66
use crate::{queries::Query, rows_to_frame, Error, MaterializePlugin, Result};
77

88
/// Convert a Grafana Plugin SDK Frame to some initial data to send to new subscribers.
9-
fn frame_to_initial_data(frame: data::Frame) -> Result<backend::InitialData> {
9+
fn frame_to_initial_data(frame: &data::Frame) -> Result<backend::InitialData> {
1010
let checked = frame.check()?;
1111
Ok(backend::InitialData::from_frame(
1212
checked,
@@ -37,7 +37,7 @@ impl backend::StreamService for MaterializePlugin {
3737

3838
Ok(backend::SubscribeStreamResponse::new(
3939
backend::SubscribeStreamStatus::Ok,
40-
Some(frame_to_initial_data(rows_to_frame(initial_rows))?),
40+
Some(frame_to_initial_data(&rows_to_frame(&initial_rows))?),
4141
))
4242
}
4343

@@ -64,7 +64,7 @@ impl backend::StreamService for MaterializePlugin {
6464
.await?
6565
.map_err(Error::Connection)
6666
.and_then(|row| async {
67-
rows_to_frame(vec![row])
67+
rows_to_frame(&[row])
6868
.check()
6969
.map_err(Error::Data)
7070
.and_then(|f| Ok(backend::StreamPacket::from_frame(f)?))

‎xtask/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn print_help() {
1515
"Tasks:
1616
watch [release] watch for changes, then compile plugin (optionally in release mode), replace in `dist` directory, and restart plugin process
1717
"
18-
)
18+
);
1919
}
2020

2121
fn go_target() -> Result<String, Box<dyn Error>> {

0 commit comments

Comments
 (0)