feat: add UserBlockInfo model to show block size instead of index

This commit is contained in:
Sameh Abouel-saad
2025-06-24 18:13:02 +03:00
parent b81a0aa61c
commit ba6f53a28a
9 changed files with 57 additions and 6 deletions

View File

@@ -92,6 +92,8 @@ pub mod template_err_not_found;
pub use self::template_err_not_found::TemplateErrNotFound;
pub mod upload_block_params;
pub use self::upload_block_params::UploadBlockParams;
pub mod user_block_info;
pub use self::user_block_info::UserBlockInfo;
pub mod user_blocks_response;
pub use self::user_blocks_response::UserBlocksResponse;
pub mod verify_block;

View File

@@ -0,0 +1,34 @@
/*
* rfs
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.2.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// UserBlockInfo : Block information with hash and size
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UserBlockInfo {
/// Block hash
#[serde(rename = "hash")]
pub hash: String,
/// Block size in bytes
#[serde(rename = "size")]
pub size: i64,
}
impl UserBlockInfo {
/// Block information with hash and size
pub fn new(hash: String, size: i64) -> UserBlockInfo {
UserBlockInfo {
hash,
size,
}
}
}

View File

@@ -17,9 +17,9 @@ pub struct UserBlocksResponse {
/// Total number of all blocks
#[serde(rename = "all_blocks")]
pub all_blocks: i64,
/// List of blocks with their indices
/// List of blocks with their sizes
#[serde(rename = "blocks")]
pub blocks: Vec<models::BlockInfo>,
pub blocks: Vec<models::UserBlockInfo>,
/// Total number of blocks
#[serde(rename = "total")]
pub total: i64,
@@ -27,7 +27,7 @@ pub struct UserBlocksResponse {
impl UserBlocksResponse {
/// Response for user blocks endpoint
pub fn new(all_blocks: i64, blocks: Vec<models::BlockInfo>, total: i64) -> UserBlocksResponse {
pub fn new(all_blocks: i64, blocks: Vec<models::UserBlockInfo>, total: i64) -> UserBlocksResponse {
UserBlocksResponse {
all_blocks,
blocks,