Bump rust edition & reformat

This commit is contained in:
Andras Schmelczer 2025-01-07 22:25:59 +00:00
commit f4a87d073a
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
15 changed files with 44 additions and 45 deletions

View file

@ -10,7 +10,7 @@ members = [
[workspace.package] [workspace.package]
rust-version = "1.83" rust-version = "1.83"
authors = ["Andras Schmelczer <andras@schmelczer.dev>"] authors = ["Andras Schmelczer <andras@schmelczer.dev>"]
edition = "2022" edition = "2024"
license = "MIT" license = "MIT"
repository = "https://github.com/schmelczer/vault-link" repository = "https://github.com/schmelczer/vault-link"
version = "0.0.20" version = "0.0.20"

View file

@ -3,5 +3,5 @@ mod operation_transformation;
mod tokenizer; mod tokenizer;
mod utils; mod utils;
pub use operation_transformation::{reconcile, reconcile_with_tokenizer, EditedText}; pub use operation_transformation::{EditedText, reconcile, reconcile_with_tokenizer};
pub use tokenizer::token::Token; pub use tokenizer::token::Token;

View file

@ -7,7 +7,7 @@ use super::Operation;
use crate::{ use crate::{
diffs::{myers::diff, raw_operation::RawOperation}, diffs::{myers::diff, raw_operation::RawOperation},
operation_transformation::merge_context::MergeContext, operation_transformation::merge_context::MergeContext,
tokenizer::{word_tokenizer::word_tokenizer, Tokenizer}, tokenizer::{Tokenizer, word_tokenizer::word_tokenizer},
utils::{ utils::{
merge_iters::MergeSorted as _, ordered_operation::OrderedOperation, side::Side, merge_iters::MergeSorted as _, ordered_operation::OrderedOperation, side::Side,
string_builder::StringBuilder, string_builder::StringBuilder,

View file

@ -8,8 +8,8 @@ use serde::{Deserialize, Serialize};
use super::merge_context::MergeContext; use super::merge_context::MergeContext;
use crate::{ use crate::{
utils::{find_common_overlap::find_common_overlap, string_builder::StringBuilder},
Token, Token,
utils::{find_common_overlap::find_common_overlap, string_builder::StringBuilder},
}; };
/// Represents a change that can be applied to a text document. /// Represents a change that can be applied to a text document.
@ -355,9 +355,11 @@ mod tests {
#[test] #[test]
#[should_panic] #[should_panic]
fn test_shifting_error() { fn test_shifting_error() {
insta::assert_debug_snapshot!(Operation::create_insert(1, vec!["hi".into()]) insta::assert_debug_snapshot!(
Operation::create_insert(1, vec!["hi".into()])
.unwrap() .unwrap()
.with_shifted_index(-2)); .with_shifted_index(-2)
);
} }
#[test] #[test]

View file

@ -40,26 +40,29 @@ mod tests {
assert_eq!(find_common_overlap(&["".into()], &["".into()]), 0); assert_eq!(find_common_overlap(&["".into()], &["".into()]), 0);
assert_eq!( assert_eq!(
find_common_overlap( find_common_overlap(&["a".into(), "b".into(), "c".into()], &[
&["a".into(), "b".into(), "c".into()], "b".into(),
&["b".into(), "c".into(), "a".into()] "c".into(),
), "a".into()
]),
1 1
); );
assert_eq!( assert_eq!(
find_common_overlap( find_common_overlap(&["a".into(), "a".into(), "a".into()], &[
&["a".into(), "a".into(), "a".into()], "a".into(),
&["a".into(), "b".into(), "c".into()] "b".into(),
), "c".into()
]),
2 2
); );
assert_eq!( assert_eq!(
find_common_overlap( find_common_overlap(&["a".into(), "b".into(), "c".into()], &[
&["a".into(), "b".into(), "c".into()], "d".into(),
&["d".into(), "e".into(), "a".into()] "e".into(),
), "a".into()
]),
3 3
); );

View file

@ -10,7 +10,7 @@
//! - `errors`: Contains error types used in this crate. //! - `errors`: Contains error types used in this crate.
use core::str; use core::str;
use base64::{engine::general_purpose::STANDARD, Engine as _}; use base64::{Engine as _, engine::general_purpose::STANDARD};
use errors::SyncLibError; use errors::SyncLibError;
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;

View file

@ -1,4 +1,4 @@
use rand::{distributions::Alphanumeric, thread_rng, Rng as _}; use rand::{Rng as _, distributions::Alphanumeric, thread_rng};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone)] #[derive(Debug, Deserialize, Serialize, Clone)]

View file

@ -6,7 +6,7 @@ use models::{
}; };
use sqlx::{sqlite::SqliteConnectOptions, types::chrono::Utc}; use sqlx::{sqlite::SqliteConnectOptions, types::chrono::Utc};
pub mod models; pub mod models;
use sqlx::{sqlite::SqlitePoolOptions, Pool, Sqlite}; use sqlx::{Pool, Sqlite, sqlite::SqlitePoolOptions};
use crate::config::database_config::DatabaseConfig; use crate::config::database_config::DatabaseConfig;

View file

@ -1,8 +1,8 @@
use aide::OperationOutput; use aide::OperationOutput;
use axum::{ use axum::{
Json,
http::StatusCode, http::StatusCode,
response::{IntoResponse, Response}, response::{IntoResponse, Response},
Json,
}; };
use log::{error, info}; use log::{error, info};
use schemars::JsonSchema; use schemars::JsonSchema;

View file

@ -6,7 +6,7 @@ mod server;
mod utils; mod utils;
use anyhow::{Context as _, Result}; use anyhow::{Context as _, Result};
use errors::{init_error, SyncServerError}; use errors::{SyncServerError, init_error};
use log::info; use log::info;
use server::create_server; use server::create_server;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

View file

@ -1,7 +1,7 @@
use super::app_state::AppState; use super::app_state::AppState;
use crate::{ use crate::{
config::user_config::User, config::user_config::User,
errors::{unauthorized_error, SyncServerError}, errors::{SyncServerError, unauthorized_error},
}; };
pub fn auth(app_state: &AppState, token: &str) -> Result<User, SyncServerError> { pub fn auth(app_state: &AppState, token: &str) -> Result<User, SyncServerError> {

View file

@ -1,19 +1,17 @@
use anyhow::Context as _; use anyhow::Context as _;
use axum::{ use axum::extract::{Path, State};
extract::{Path, State},
Json,
};
use axum_extra::{ use axum_extra::{
headers::{authorization::Bearer, Authorization},
TypedHeader, TypedHeader,
headers::{Authorization, authorization::Bearer},
}; };
use axum_jsonschema::Json;
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use super::{app_state::AppState, auth::auth, requests::DeleteDocumentVersion}; use super::{app_state::AppState, auth::auth, requests::DeleteDocumentVersion};
use crate::{ use crate::{
database::models::{DocumentId, StoredDocumentVersion, VaultId}, database::models::{DocumentId, StoredDocumentVersion, VaultId},
errors::{server_error, SyncServerError}, errors::{SyncServerError, server_error},
utils::sanitize_path, utils::sanitize_path,
}; };

View file

@ -1,19 +1,17 @@
use anyhow::anyhow; use anyhow::anyhow;
use axum::{ use axum::extract::{Path, State};
extract::{Path, State},
Json,
};
use axum_extra::{ use axum_extra::{
headers::{authorization::Bearer, Authorization},
TypedHeader, TypedHeader,
headers::{Authorization, authorization::Bearer},
}; };
use axum_jsonschema::Json;
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use super::{app_state::AppState, auth::auth}; use super::{app_state::AppState, auth::auth};
use crate::{ use crate::{
database::models::{DocumentId, DocumentVersion, VaultId}, database::models::{DocumentId, DocumentVersion, VaultId},
errors::{not_found_error, server_error, SyncServerError}, errors::{SyncServerError, not_found_error, server_error},
}; };
// This is required for aide to infer the path parameter types and names // This is required for aide to infer the path parameter types and names

View file

@ -1,18 +1,16 @@
use axum::{ use axum::extract::{Path, Query, State};
extract::{Path, Query, State},
Json,
};
use axum_extra::{ use axum_extra::{
headers::{authorization::Bearer, Authorization},
TypedHeader, TypedHeader,
headers::{Authorization, authorization::Bearer},
}; };
use axum_jsonschema::Json;
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use super::{app_state::AppState, auth::auth, responses::FetchLatestDocumentsResponse}; use super::{app_state::AppState, auth::auth, responses::FetchLatestDocumentsResponse};
use crate::{ use crate::{
database::models::{VaultId, VaultUpdateId}, database::models::{VaultId, VaultUpdateId},
errors::{server_error, SyncServerError}, errors::{SyncServerError, server_error},
}; };
// This is required for aide to infer the path parameter types and names // This is required for aide to infer the path parameter types and names

View file

@ -1,7 +1,7 @@
use axum::{extract::State, Json}; use axum::{Json, extract::State};
use axum_extra::{ use axum_extra::{
headers::{authorization::Bearer, Authorization},
TypedHeader, TypedHeader,
headers::{Authorization, authorization::Bearer},
}; };
use super::{app_state::AppState, auth::auth, responses::PingResponse}; use super::{app_state::AppState, auth::auth, responses::PingResponse};