Clippy
This commit is contained in:
parent
2ba158a0d4
commit
0cac6a0094
3 changed files with 16 additions and 13 deletions
|
|
@ -110,8 +110,10 @@ async fn create_token(tokens: &TokenStore) -> anyhow::Result<(i32, i32, ResetCan
|
|||
let mut tokens = tokens.lock().await;
|
||||
loop {
|
||||
let pid_key = random_pid_key();
|
||||
if !tokens.contains_key(&pid_key) {
|
||||
tokens.insert(pid_key, token.clone());
|
||||
|
||||
use std::collections::hash_map;
|
||||
if let hash_map::Entry::Vacant(token_entry) = tokens.entry(pid_key) {
|
||||
token_entry.insert(token.clone());
|
||||
|
||||
let (pid, key) = pid_key;
|
||||
return Ok((pid, key, token));
|
||||
|
|
@ -187,7 +189,7 @@ async fn handle_query<W>(writer: &mut W, state: &SharedDbState, query: String, t
|
|||
true
|
||||
}
|
||||
Response::Selected(schema, columns, mut rows) => {
|
||||
writer.write_table_header(&schema, &columns).await?;
|
||||
writer.write_table_header(schema, &columns).await?;
|
||||
match rows.next() {
|
||||
Some(row) => {
|
||||
writer.write_table_row(&row).await?;
|
||||
|
|
@ -223,7 +225,7 @@ async fn handle_query<W>(writer: &mut W, state: &SharedDbState, query: String, t
|
|||
|
||||
if need_write {
|
||||
let state = state.read().await;
|
||||
state_to_file(&state, &config.get_file_path()).await?;
|
||||
state_to_file(&state, config.get_file_path()).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use async_trait::async_trait;
|
|||
use rand::Rng;
|
||||
use rand_pcg::Pcg64;
|
||||
use rand_seeder::Seeder;
|
||||
use std::fmt;
|
||||
use minisql::operation::ColumnSelection;
|
||||
use minisql::restricted_row::RestrictedRow;
|
||||
use minisql::schema::{Column, TableSchema};
|
||||
|
|
@ -20,14 +21,14 @@ pub enum CompleteStatus {
|
|||
CreateIndex,
|
||||
}
|
||||
|
||||
impl CompleteStatus {
|
||||
fn to_string(&self) -> String {
|
||||
impl fmt::Display for CompleteStatus {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CompleteStatus::Insert { oid, rows } => format!("INSERT {} {}", oid, rows),
|
||||
CompleteStatus::Delete(rows) => format!("DELETE {}", rows),
|
||||
CompleteStatus::Select(rows) => format!("SELECT {}", rows),
|
||||
CompleteStatus::CreateTable => "CREATE TABLE".to_string(),
|
||||
CompleteStatus::CreateIndex => "CREATE INDEX".to_string(),
|
||||
CompleteStatus::Insert { oid, rows } => write!(f, "INSERT {} {}", oid, rows),
|
||||
CompleteStatus::Delete(rows) => write!(f, "DELETE {}", rows),
|
||||
CompleteStatus::Select(rows) => write!(f, "SELECT {}", rows),
|
||||
CompleteStatus::CreateTable => write!(f, "CREATE TABLE"),
|
||||
CompleteStatus::CreateIndex => write!(f, "CREATE INDEX"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -118,4 +119,4 @@ fn column_to_description(schema: &TableSchema, column: Column) -> anyhow::Result
|
|||
fn table_name_to_oid(table_name: &str) -> i32 {
|
||||
let mut rng: Pcg64 = Seeder::from(table_name).make_rng();
|
||||
rng.gen::<i32>()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue