diff --git a/native/src/lib.rs b/native/src/lib.rs index 6efd16b..ec71b51 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -83,7 +83,7 @@ pub struct MessagePreview { pub struct Dialog { id: String, title: String, - lastMessage: Option, + last_message: Option, pinned: bool, } @@ -104,7 +104,7 @@ fn block_on(future: F) -> F::Output { RUNTIME.get().unwrap().block_on(future) } -pub fn initDatabase(path: String) -> Result<()> { +pub fn init_database(path: String) -> Result<()> { let mut guard = DATABASE.lock().unwrap(); if guard.is_some() { info!("Database is already initialized"); @@ -119,7 +119,7 @@ pub fn initDatabase(path: String) -> Result<()> { } } -pub fn initClient() -> Result<()> { +pub fn init_client() -> Result<()> { android_logger::init_once( android_logger::Config::default() .with_min_level(LOG_MIN_LEVEL) @@ -194,19 +194,19 @@ pub fn initClient() -> Result<()> { Ok(()) } -pub fn needLogin() -> Result { +pub fn need_login() -> Result { let client = CLIENT.get().ok_or(NativeError::Initialization)?; block_on(client.is_authorized()).map_err(|_| NativeError::Network) } -pub fn requestLoginCode(phone: String) -> Result { +pub fn request_login_code(phone: String) -> Result { let client = CLIENT.get().ok_or(NativeError::Initialization)?; block_on(client.request_login_code(&phone, API_ID, API_HASH)) .map(|token| Box::into_raw(Box::new(token)) as u64) .map_err(|_| NativeError::Network) } -pub fn signIn(token_ptr: u64, code: String) -> Result<()> { +pub fn sign_in(token_ptr: u64, code: String) -> Result<()> { let token = unsafe { *Box::from_raw(token_ptr as *mut LoginToken) }; let client = CLIENT.get().ok_or(NativeError::Initialization)?; @@ -256,7 +256,7 @@ pub fn signIn(token_ptr: u64, code: String) -> Result<()> { Ok(()) } -pub fn getDialogs() -> Result> { +pub fn get_dialogs() -> Result> { let client = CLIENT.get().ok_or(NativeError::Initialization)?; block_on(async { @@ -273,7 +273,7 @@ pub fn getDialogs() -> Result> { .map(|d| Dialog { id: d.chat().pack().to_hex(), title: d.chat().name().to_string(), - lastMessage: d.last_message.map(|m| MessagePreview { + last_message: d.last_message.map(|m| MessagePreview { sender: if let Some(sender) = m.sender() { sender.name().to_string() } else { @@ -305,7 +305,7 @@ pub fn getDialogs() -> Result> { }) } -pub fn sendMessage(packed: String, text: String) -> Result<()> { +pub fn send_message(packed: String, text: String) -> Result<()> { let chat = PackedChat::from_hex(&packed).unwrap(); let client = CLIENT.get().ok_or(NativeError::Initialization)?; block_on(client.send_message(chat, text)).map_err(|_| NativeError::Network)?; diff --git a/native/src/talaria.udl b/native/src/talaria.udl index 41f5157..d267cef 100644 --- a/native/src/talaria.udl +++ b/native/src/talaria.udl @@ -21,23 +21,23 @@ dictionary MessagePreview { dictionary Dialog { string id; string title; - MessagePreview? lastMessage; + MessagePreview? last_message; boolean pinned; }; namespace talaria { [Throws=NativeError] - void initDatabase(string path); + void init_database(string path); [Throws=NativeError] - void initClient(); + void init_client(); [Throws=NativeError] - boolean needLogin(); + boolean need_login(); [Throws=NativeError] - u64 requestLoginCode(string phone); + u64 request_login_code(string phone); [Throws=NativeError] - void signIn(u64 tokenPtr, string code); + void sign_in(u64 tokenPtr, string code); [Throws=NativeError] - sequence getDialogs(); + sequence get_dialogs(); [Throws=NativeError] - void sendMessage(string packed, string text); + void send_message(string packed, string text); };