From cd37c5aa1494a08b5453da9b786b5a60e0538276 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 20 Oct 2022 20:06:22 +0200 Subject: [PATCH] Run cargo fmt on the project IDE Action on Save seemed to be messing with the ordering. --- native/src/db/mod.rs | 14 ++++++-------- native/src/lib.rs | 23 +++++++++++------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/native/src/db/mod.rs b/native/src/db/mod.rs index f70fb74..2f9d1b4 100644 --- a/native/src/db/mod.rs +++ b/native/src/db/mod.rs @@ -1,13 +1,11 @@ -use std::net::IpAddr; - -use sqlite::{Connection, Error, State}; - -use model::Session; -use utils::{fetch_many, fetch_one}; - mod model; mod utils; +use model::Session; +use sqlite::{Connection, Error, State}; +use std::net::IpAddr; +use utils::{fetch_many, fetch_one}; + fn init_schema(conn: &Connection) -> Result<(), Error> { let version = match fetch_one(&conn, "SELECT version FROM version LIMIT 1", |stmt| { stmt.read::(0) @@ -92,7 +90,7 @@ pub fn create_session(conn: &Connection) -> Result { let id = fetch_one(conn, "SELECT LAST_INSERT_ROWID()", |stmt| { stmt.read::(0) })? - .unwrap(); + .unwrap(); Ok(Session { id, user_id: None, diff --git a/native/src/lib.rs b/native/src/lib.rs index afd7442..0048979 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -1,34 +1,33 @@ #![cfg(target_os = "android")] #![allow(non_snake_case)] -use std::collections::HashMap; -use std::ffi::{CStr, CString}; -use std::future::Future; -use std::net::{Ipv4Addr, Ipv6Addr}; -use std::net::SocketAddr; -use std::sync::Mutex; +mod db; -use grammers_client::{Client, Config}; use grammers_client::types::{Dialog, LoginToken}; +use grammers_client::{Client, Config}; use grammers_session::{PackedChat, Session, UpdateState}; -use jni::JNIEnv; use jni::objects::{JObject, JString}; use jni::sys::{jboolean, jint, jlong, jstring}; +use jni::JNIEnv; use log; use log::{error, info, Level}; use once_cell::sync::OnceCell; +use std::collections::HashMap; +use std::ffi::{CStr, CString}; +use std::future::Future; +use std::net::SocketAddr; +use std::net::{Ipv4Addr, Ipv6Addr}; +use std::sync::Mutex; use tokio::runtime; use tokio::runtime::Runtime; -mod db; +type Result = std::result::Result>; const LOG_MIN_LEVEL: Level = Level::Trace; const LOG_TAG: &str = ".native.talari"; const API_ID: i32 = 0; const API_HASH: &str = ""; -type Result = std::result::Result>; - static RUNTIME: OnceCell = OnceCell::new(); static CLIENT: OnceCell = OnceCell::new(); static DATABASE: Mutex> = Mutex::new(None); @@ -104,7 +103,7 @@ async fn init_client() -> Result<()> { api_hash: API_HASH.to_string(), params: Default::default(), }) - .await?; + .await?; info!("Connected!");