Compare commits
No commits in common. "ba6f53a28a12ad3e9d75976db291132d681a0b97" and "b02101bd427c336dda7ee264c0faa6cfa601e3b6" have entirely different histories.
ba6f53a28a
...
b02101bd42
@ -11,18 +11,17 @@ categories = ["os", "filesystem", "api-bindings"]
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [".", "vault", "git", "redisclient", "mycelium", "text", "os", "net", "zinit_client", "process", "virt", "postgresclient", "rhai", "herodo", "rfs-client"]
|
members = [".", "vault", "git", "redisclient", "mycelium", "text", "os", "net", "zinit_client", "process", "virt", "postgresclient", "rhai", "herodo"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.metadata]
|
[workspace.metadata]
|
||||||
# Workspace-level metadata
|
# Workspace-level metadata
|
||||||
rust-version = "1.85.0"
|
rust-version = "1.70.0"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
# Core shared dependencies with consistent versions
|
# Core shared dependencies with consistent versions
|
||||||
anyhow = "1.0.98"
|
anyhow = "1.0.98"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
bytes = "1.4.0"
|
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
env_logger = "0.11.8"
|
env_logger = "0.11.8"
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
@ -85,4 +84,3 @@ sal-virt = { path = "virt" }
|
|||||||
sal-postgresclient = { path = "postgresclient" }
|
sal-postgresclient = { path = "postgresclient" }
|
||||||
sal-vault = { path = "vault" }
|
sal-vault = { path = "vault" }
|
||||||
sal-rhai = { path = "rhai" }
|
sal-rhai = { path = "rhai" }
|
||||||
sal-rfs-client = { path = "rfs-client" }
|
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sal-rfs-client"
|
name = "rfs-client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "SAL RFS Client - Client library for Remote File System server"
|
description = "Client library for RFS (Remote File System) server"
|
||||||
repository = "https://git.threefold.info/herocode/sal"
|
license = "MIT"
|
||||||
license = "Apache-2.0"
|
|
||||||
keywords = ["rfs", "client", "filesystem", "remote"]
|
|
||||||
categories = ["filesystem", "api-bindings"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
openapi = { path = "./openapi" }
|
openapi = { path = "./openapi" }
|
||||||
thiserror.workspace = true
|
thiserror = "1.0"
|
||||||
url.workspace = true
|
url = "2.4"
|
||||||
reqwest = { workspace = true, features = ["json", "multipart"] }
|
reqwest = { version = "^0.12", features = ["json", "multipart"] }
|
||||||
tokio = { workspace = true, features = ["full"] }
|
tokio = { version = "1.28", features = ["full"] }
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json.workspace = true
|
serde_json = "1.0"
|
||||||
log.workspace = true
|
log = "0.4"
|
||||||
bytes.workspace = true
|
bytes = "1.4"
|
||||||
futures.workspace = true
|
futures = "0.3"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use sal_rfs_client::RfsClient;
|
use rfs_client::RfsClient;
|
||||||
use sal_rfs_client::types::{ClientConfig, Credentials};
|
use rfs_client::types::{ClientConfig, Credentials};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use sal_rfs_client::RfsClient;
|
use rfs_client::RfsClient;
|
||||||
use sal_rfs_client::types::{ClientConfig, Credentials};
|
use rfs_client::types::{ClientConfig, Credentials};
|
||||||
use openapi::models::{VerifyBlock, VerifyBlocksRequest};
|
use openapi::models::{VerifyBlock, VerifyBlocksRequest};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@ -109,7 +109,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let user_blocks = client.get_user_blocks(Some(1), Some(10)).await?;
|
let user_blocks = client.get_user_blocks(Some(1), Some(10)).await?;
|
||||||
println!("User has {} blocks (showing page 1 with 10 per page)", user_blocks.total);
|
println!("User has {} blocks (showing page 1 with 10 per page)", user_blocks.total);
|
||||||
for block in user_blocks.blocks.iter().take(3) {
|
for block in user_blocks.blocks.iter().take(3) {
|
||||||
println!(" - Block: {}, Size: {}", block.hash, block.size);
|
println!(" - Block: {}, Index: {}", block.hash, block.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload a block (upload_block_handler)
|
// Upload a block (upload_block_handler)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use sal_rfs_client::RfsClient;
|
use rfs_client::RfsClient;
|
||||||
use sal_rfs_client::types::{ClientConfig, Credentials, UploadOptions, DownloadOptions};
|
use rfs_client::types::{ClientConfig, Credentials, UploadOptions, DownloadOptions};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use sal_rfs_client::RfsClient;
|
use rfs_client::RfsClient;
|
||||||
use sal_rfs_client::types::{ClientConfig, Credentials, FlistOptions, WaitOptions};
|
use rfs_client::types::{ClientConfig, Credentials, FlistOptions, WaitOptions};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use sal_rfs_client::RfsClient;
|
use rfs_client::RfsClient;
|
||||||
use sal_rfs_client::types::{ClientConfig, Credentials, WaitOptions};
|
use rfs_client::types::{ClientConfig, Credentials, WaitOptions};
|
||||||
use openapi::models::FlistState;
|
use openapi::models::FlistState;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
File diff suppressed because one or more lines are too long
@ -54,7 +54,6 @@ docs/TemplateErrBadRequest.md
|
|||||||
docs/TemplateErrInternalServerError.md
|
docs/TemplateErrInternalServerError.md
|
||||||
docs/TemplateErrNotFound.md
|
docs/TemplateErrNotFound.md
|
||||||
docs/UploadBlockParams.md
|
docs/UploadBlockParams.md
|
||||||
docs/UserBlockInfo.md
|
|
||||||
docs/UserBlocksResponse.md
|
docs/UserBlocksResponse.md
|
||||||
docs/VerifyBlock.md
|
docs/VerifyBlock.md
|
||||||
docs/VerifyBlocksRequest.md
|
docs/VerifyBlocksRequest.md
|
||||||
@ -118,7 +117,6 @@ src/models/template_err_bad_request.rs
|
|||||||
src/models/template_err_internal_server_error.rs
|
src/models/template_err_internal_server_error.rs
|
||||||
src/models/template_err_not_found.rs
|
src/models/template_err_not_found.rs
|
||||||
src/models/upload_block_params.rs
|
src/models/upload_block_params.rs
|
||||||
src/models/user_block_info.rs
|
|
||||||
src/models/user_blocks_response.rs
|
src/models/user_blocks_response.rs
|
||||||
src/models/verify_block.rs
|
src/models/verify_block.rs
|
||||||
src/models/verify_blocks_request.rs
|
src/models/verify_blocks_request.rs
|
||||||
|
@ -95,7 +95,6 @@ Class | Method | HTTP request | Description
|
|||||||
- [TemplateErrInternalServerError](docs/TemplateErrInternalServerError.md)
|
- [TemplateErrInternalServerError](docs/TemplateErrInternalServerError.md)
|
||||||
- [TemplateErrNotFound](docs/TemplateErrNotFound.md)
|
- [TemplateErrNotFound](docs/TemplateErrNotFound.md)
|
||||||
- [UploadBlockParams](docs/UploadBlockParams.md)
|
- [UploadBlockParams](docs/UploadBlockParams.md)
|
||||||
- [UserBlockInfo](docs/UserBlockInfo.md)
|
|
||||||
- [UserBlocksResponse](docs/UserBlocksResponse.md)
|
- [UserBlocksResponse](docs/UserBlocksResponse.md)
|
||||||
- [VerifyBlock](docs/VerifyBlock.md)
|
- [VerifyBlock](docs/VerifyBlock.md)
|
||||||
- [VerifyBlocksRequest](docs/VerifyBlocksRequest.md)
|
- [VerifyBlocksRequest](docs/VerifyBlocksRequest.md)
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
# UserBlockInfo
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**hash** | **String** | Block hash |
|
|
||||||
**size** | **i64** | Block size in bytes |
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**all_blocks** | **i64** | Total number of all blocks |
|
**all_blocks** | **i64** | Total number of all blocks |
|
||||||
**blocks** | [**Vec<models::UserBlockInfo>**](UserBlockInfo.md) | List of blocks with their sizes |
|
**blocks** | [**Vec<models::BlockInfo>**](BlockInfo.md) | List of blocks with their indices |
|
||||||
**total** | **i64** | Total number of blocks |
|
**total** | **i64** | Total number of blocks |
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
@ -92,8 +92,6 @@ pub mod template_err_not_found;
|
|||||||
pub use self::template_err_not_found::TemplateErrNotFound;
|
pub use self::template_err_not_found::TemplateErrNotFound;
|
||||||
pub mod upload_block_params;
|
pub mod upload_block_params;
|
||||||
pub use self::upload_block_params::UploadBlockParams;
|
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 mod user_blocks_response;
|
||||||
pub use self::user_blocks_response::UserBlocksResponse;
|
pub use self::user_blocks_response::UserBlocksResponse;
|
||||||
pub mod verify_block;
|
pub mod verify_block;
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -17,9 +17,9 @@ pub struct UserBlocksResponse {
|
|||||||
/// Total number of all blocks
|
/// Total number of all blocks
|
||||||
#[serde(rename = "all_blocks")]
|
#[serde(rename = "all_blocks")]
|
||||||
pub all_blocks: i64,
|
pub all_blocks: i64,
|
||||||
/// List of blocks with their sizes
|
/// List of blocks with their indices
|
||||||
#[serde(rename = "blocks")]
|
#[serde(rename = "blocks")]
|
||||||
pub blocks: Vec<models::UserBlockInfo>,
|
pub blocks: Vec<models::BlockInfo>,
|
||||||
/// Total number of blocks
|
/// Total number of blocks
|
||||||
#[serde(rename = "total")]
|
#[serde(rename = "total")]
|
||||||
pub total: i64,
|
pub total: i64,
|
||||||
@ -27,7 +27,7 @@ pub struct UserBlocksResponse {
|
|||||||
|
|
||||||
impl UserBlocksResponse {
|
impl UserBlocksResponse {
|
||||||
/// Response for user blocks endpoint
|
/// Response for user blocks endpoint
|
||||||
pub fn new(all_blocks: i64, blocks: Vec<models::UserBlockInfo>, total: i64) -> UserBlocksResponse {
|
pub fn new(all_blocks: i64, blocks: Vec<models::BlockInfo>, total: i64) -> UserBlocksResponse {
|
||||||
UserBlocksResponse {
|
UserBlocksResponse {
|
||||||
all_blocks,
|
all_blocks,
|
||||||
blocks,
|
blocks,
|
||||||
|
3
rfs-client/rust-toolchain.toml
Normal file
3
rfs-client/rust-toolchain.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "1.82.0"
|
||||||
|
|
@ -12,8 +12,8 @@ use openapi::{
|
|||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
SignInBody, ListBlocksParams,
|
SignInBody, ListBlocksParams,
|
||||||
VerifyBlocksRequest, VerifyBlocksResponse, FlistBody, UserBlocksResponse, BlockDownloadsResponse,
|
VerifyBlocksRequest, VerifyBlocksResponse, VerifyBlock, FlistBody, UserBlocksResponse, BlockDownloadsResponse,
|
||||||
BlocksResponse, PreviewResponse, FileInfo, FlistState, FlistStateResponse,
|
BlocksResponse, PreviewResponse, FileInfo, FlistState, ResponseResult, FlistStateResponse, BlockUploadedResponse, FileUploadResponse,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,7 +122,12 @@ impl RfsClient {
|
|||||||
.map_err(map_openapi_error)?;
|
.map_err(map_openapi_error)?;
|
||||||
|
|
||||||
// Extract the file hash from the response
|
// Extract the file hash from the response
|
||||||
Ok(result.file_hash.clone())
|
match result {
|
||||||
|
FileUploadResponse { file_hash, .. } => {
|
||||||
|
Ok(file_hash.clone())
|
||||||
|
},
|
||||||
|
_ => Err(RfsError::Other("Unexpected response type from file upload".to_string())),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Download a file from the RFS server
|
/// Download a file from the RFS server
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
[toolchain]
|
|
||||||
channel = "1.85.0"
|
|
||||||
|
|
@ -43,7 +43,6 @@ pub use sal_os as os;
|
|||||||
pub use sal_postgresclient as postgresclient;
|
pub use sal_postgresclient as postgresclient;
|
||||||
pub use sal_process as process;
|
pub use sal_process as process;
|
||||||
pub use sal_redisclient as redisclient;
|
pub use sal_redisclient as redisclient;
|
||||||
pub use sal_rfs_client as rfs_client;
|
|
||||||
pub use sal_rhai as rhai;
|
pub use sal_rhai as rhai;
|
||||||
pub use sal_text as text;
|
pub use sal_text as text;
|
||||||
pub use sal_vault as vault;
|
pub use sal_vault as vault;
|
||||||
|
Loading…
Reference in New Issue
Block a user