From 938b36c8634763a83ca282d30bb3ef08c02aec18 Mon Sep 17 00:00:00 2001 From: amigin Date: Tue, 24 Dec 2024 13:01:59 +0200 Subject: [PATCH] Fixes --- .../http_connection/into_http_payload.rs | 34 ++++--------------- .../tcp_connection/tcp_payload_to_send.rs | 7 ++-- .../read/get_highest_row_and_below.rs | 4 ++- src/db_operations/read/multipart.rs | 2 +- src/db_operations/read/rows/get_all.rs | 4 ++- .../read/rows/get_all_by_partition_key.rs | 4 ++- .../read/rows/get_all_by_row_key.rs | 4 ++- .../get_single_partition_multiple_rows.rs | 4 ++- .../states/delete_rows_event_sync_data.rs | 2 +- src/settings_reader.rs | 2 +- src/zip/db_zip_builder.rs | 2 +- 11 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/data_readers/http_connection/into_http_payload.rs b/src/data_readers/http_connection/into_http_payload.rs index 583772a..8f7f116 100644 --- a/src/data_readers/http_connection/into_http_payload.rs +++ b/src/data_readers/http_connection/into_http_payload.rs @@ -33,17 +33,12 @@ fn write_init_table_result(table_name: &str, content: JsonArrayWriter) -> Vec Vec< let mut header_json = JsonObjectWriter::new(); header_json.write("tableName", sync_data.table_data.table_name.as_str()); - let header = unsafe { - format!( - "initPartitions:{}", - std::str::from_utf8_unchecked(header_json.build().as_slice()) - ) - }; + let header = format!("initPartitions:{}", header_json.build()); write_pascal_string(header.as_str(), &mut result); let content = sync_data.as_json().build(); - write_byte_array(content.as_slice(), &mut result); + write_byte_array(content.as_bytes(), &mut result); result } @@ -72,17 +62,12 @@ pub fn compile_update_rows_result(sync_data: &UpdateRowsSyncData) -> Vec { let mut header_json = JsonObjectWriter::new(); header_json.write("tableName", sync_data.table_data.table_name.as_str()); - let header = unsafe { - format!( - "updateRows:{}", - std::str::from_utf8_unchecked(header_json.build().as_slice()) - ) - }; + let header = format!("updateRows:{}", header_json.build()); write_pascal_string(header.as_str(), &mut result); let content = sync_data.rows_by_partition.as_json_array().build(); - write_byte_array(content.as_slice(), &mut result); + write_byte_array(content.as_bytes(), &mut result); result } @@ -92,12 +77,7 @@ pub fn compile_delete_rows_result(sync_data: &DeleteRowsEventSyncData) -> Vec Vec Vec Vec Vec { let tcp_contract = MyNoSqlTcpContract::UpdateRows { table_name: data.table_data.table_name.to_string(), - data: data.rows_by_partition.as_json_array().build(), + data: data.rows_by_partition.as_json_array().build().into_bytes(), }; if compress { diff --git a/src/db_operations/read/get_highest_row_and_below.rs b/src/db_operations/read/get_highest_row_and_below.rs index 8ff2258..33223f1 100644 --- a/src/db_operations/read/get_highest_row_and_below.rs +++ b/src/db_operations/read/get_highest_row_and_below.rs @@ -46,7 +46,9 @@ pub async fn get_highest_row_and_below( count += 1; } - return Ok(ReadOperationResult::RowsArray(json_array_writer.build())); + return Ok(ReadOperationResult::RowsArray( + json_array_writer.build().into_bytes(), + )); /* let mut json_array_writer = JsonArrayWriter::new(); diff --git a/src/db_operations/read/multipart.rs b/src/db_operations/read/multipart.rs index 44c3a49..0244c66 100644 --- a/src/db_operations/read/multipart.rs +++ b/src/db_operations/read/multipart.rs @@ -25,5 +25,5 @@ pub async fn get_next( ) -> Option { let db_rows = app.multipart_list.get(multipart_id, amount).await?; - ReadOperationResult::RowsArray(db_rows.as_json_array().build()).into() + ReadOperationResult::RowsArray(db_rows.as_json_array().build().into_bytes()).into() } diff --git a/src/db_operations/read/rows/get_all.rs b/src/db_operations/read/rows/get_all.rs index 3731f1f..46f407d 100644 --- a/src/db_operations/read/rows/get_all.rs +++ b/src/db_operations/read/rows/get_all.rs @@ -29,7 +29,9 @@ pub async fn get_all( json_array_writer.write(db_row.as_ref()); } - return Ok(ReadOperationResult::RowsArray(json_array_writer.build())); + return Ok(ReadOperationResult::RowsArray( + json_array_writer.build().into_bytes(), + )); } /* diff --git a/src/db_operations/read/rows/get_all_by_partition_key.rs b/src/db_operations/read/rows/get_all_by_partition_key.rs index 5135184..d9dcc51 100644 --- a/src/db_operations/read/rows/get_all_by_partition_key.rs +++ b/src/db_operations/read/rows/get_all_by_partition_key.rs @@ -40,5 +40,7 @@ pub async fn get_all_by_partition_key( }, ); - return Ok(ReadOperationResult::RowsArray(json_array_writer.build())); + return Ok(ReadOperationResult::RowsArray( + json_array_writer.build().into_bytes(), + )); } diff --git a/src/db_operations/read/rows/get_all_by_row_key.rs b/src/db_operations/read/rows/get_all_by_row_key.rs index 2e91a48..99b4b7e 100644 --- a/src/db_operations/read/rows/get_all_by_row_key.rs +++ b/src/db_operations/read/rows/get_all_by_row_key.rs @@ -30,5 +30,7 @@ pub async fn get_all_by_row_key( json_array_writer.write(db_row.as_ref()); } - return Ok(ReadOperationResult::RowsArray(json_array_writer.build())); + return Ok(ReadOperationResult::RowsArray( + json_array_writer.build().into_bytes(), + )); } diff --git a/src/db_operations/read/rows/get_single_partition_multiple_rows.rs b/src/db_operations/read/rows/get_single_partition_multiple_rows.rs index ca285bd..22f53fd 100644 --- a/src/db_operations/read/rows/get_single_partition_multiple_rows.rs +++ b/src/db_operations/read/rows/get_single_partition_multiple_rows.rs @@ -39,7 +39,9 @@ pub async fn get_single_partition_multiple_rows( json_array_writer.write(db_row.as_ref()); } } - return Ok(ReadOperationResult::RowsArray(json_array_writer.build())); + return Ok(ReadOperationResult::RowsArray( + json_array_writer.build().into_bytes(), + )); } /* diff --git a/src/db_sync/states/delete_rows_event_sync_data.rs b/src/db_sync/states/delete_rows_event_sync_data.rs index 97599e3..43929f5 100644 --- a/src/db_sync/states/delete_rows_event_sync_data.rs +++ b/src/db_sync/states/delete_rows_event_sync_data.rs @@ -140,6 +140,6 @@ impl DeleteRowsEventSyncData { } } - json_object_writer.build() + json_object_writer.build().into_bytes() } } diff --git a/src/settings_reader.rs b/src/settings_reader.rs index f5c94fa..d589b45 100644 --- a/src/settings_reader.rs +++ b/src/settings_reader.rs @@ -55,7 +55,7 @@ impl SettingsModel { my_no_sql_sdk::core::rust_extensions::file_utils::format_path(self.backup_folder.as_str()) } - pub fn get_init_from_other_server_url<'s>(&'s self) -> Option<&str> { + pub fn get_init_from_other_server_url(&self) -> Option<&str> { if let Some(url) = &self.init_from_other_server_url { return Some(url.as_str()); } diff --git a/src/zip/db_zip_builder.rs b/src/zip/db_zip_builder.rs index ffb2e37..da87b08 100644 --- a/src/zip/db_zip_builder.rs +++ b/src/zip/db_zip_builder.rs @@ -47,7 +47,7 @@ impl DbZipBuilder { let payload = json.build(); - write_to_zip_file(&mut self.zip_writer, &payload)?; + write_to_zip_file(&mut self.zip_writer, payload.as_bytes())?; } Ok(())