Skip to content

Commit 67c7171

Browse files
committed
rust 1.0.1
1 parent c520a56 commit 67c7171

File tree

19 files changed

+74
-59
lines changed

19 files changed

+74
-59
lines changed

rust/package/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/package/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "xnode-manager-sdk"
33
description = "Rust Software Development Kit for interacting with Xnode Manager"
4-
version = "1.0.0"
4+
version = "1.0.1"
55
edition = "2024"
66
repository = "https://github.com/Openmesh-Network/xnode-manager-sdk"
77
license = "MIT"

rust/package/src/auth/handlers.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use reqwest::Client;
22
use serde::{Deserialize, Serialize};
33

4-
use crate::utils::{Empty, Session, SessionPostInput, SessionPostOutput, session_post};
4+
use crate::utils::{Empty, Error, Session, SessionPostInput, SessionPostOutput, session_post};
55

66
pub fn scope() -> String {
77
"/xnode-auth".to_string()
88
}
99

10-
#[derive(Serialize, Deserialize, Debug)]
10+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
1111
pub struct User {
1212
user: String,
1313
signature: Option<String>,
@@ -30,20 +30,24 @@ impl User {
3030
}
3131
}
3232
}
33-
#[derive(Debug)]
33+
#[derive(Debug, Clone, PartialEq)]
3434
pub struct LoginInput {
3535
pub base_url: String,
3636
pub user: User,
3737
}
38-
pub type LoginOutput = Result<Session, reqwest::Error>;
38+
pub type LoginOutput = Result<Session, Error>;
3939
pub async fn login(input: LoginInput) -> LoginOutput {
40-
let client = Client::builder().cookie_store(true).build()?;
40+
let client = Client::builder()
41+
.cookie_store(true)
42+
.build()
43+
.map_err(Error::ReqwestError)?;
4144

4245
client
4346
.post(format!("{}{}/api/login", input.base_url, scope()))
4447
.json(&input.user)
4548
.send()
46-
.await?;
49+
.await
50+
.map_err(Error::ReqwestError)?;
4751

4852
Ok(Session {
4953
reqwest_client: client,

rust/package/src/config/handlers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub async fn containers(input: ContainersInput<'_>) -> SessionGetOutput<Containe
1717
session_get(input, scope(), |_path| "/containers").await
1818
}
1919

20-
#[derive(Debug)]
20+
#[derive(Debug, Clone, PartialEq)]
2121
pub struct GetPath {
2222
pub container: String,
2323
}
@@ -30,7 +30,7 @@ pub async fn get(input: GetInput<'_>) -> SessionGetOutput<GetOutput> {
3030
.await
3131
}
3232

33-
#[derive(Debug)]
33+
#[derive(Debug, Clone, PartialEq)]
3434
pub struct SetPath {
3535
pub container: String,
3636
}
@@ -43,7 +43,7 @@ pub async fn set(input: SetInput<'_>) -> SessionPostOutput<SetOutput> {
4343
.await
4444
}
4545

46-
#[derive(Debug)]
46+
#[derive(Debug, Clone, PartialEq)]
4747
pub struct RemovePath {
4848
pub container: String,
4949
}

rust/package/src/config/models.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
use serde::{Deserialize, Serialize};
22

3-
#[derive(Serialize, Deserialize, Debug)]
3+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
44
pub struct ContainerConfiguration {
55
pub flake: String,
66
pub flake_lock: Option<String>,
77
pub network: Option<String>,
88
}
99

10-
#[derive(Serialize, Deserialize, Debug)]
10+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
1111
pub struct ContainerSettings {
1212
pub flake: String,
1313
pub network: Option<String>,
1414
}
1515

16-
#[derive(Serialize, Deserialize, Debug)]
16+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
1717
pub struct ContainerChange {
1818
pub settings: ContainerSettings,
1919
pub update_inputs: Option<Vec<String>>,

rust/package/src/file/handlers.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn scope() -> String {
1313
"/file".to_string()
1414
}
1515

16+
#[derive(Debug, Clone, PartialEq)]
1617
pub struct ReadFilePath {
1718
pub scope: String,
1819
}
@@ -25,6 +26,7 @@ pub async fn read_file(input: ReadFileInput<'_>) -> SessionGetOutput<ReadFileOut
2526
.await
2627
}
2728

29+
#[derive(Debug, Clone, PartialEq)]
2830
pub struct WriteFilePath {
2931
pub scope: String,
3032
}
@@ -37,6 +39,7 @@ pub async fn write_file(input: WriteFileInput<'_>) -> SessionPostOutput<WriteFil
3739
.await
3840
}
3941

42+
#[derive(Debug, Clone, PartialEq)]
4043
pub struct RemoveFilePath {
4144
pub scope: String,
4245
}
@@ -49,7 +52,7 @@ pub async fn remove_file(input: RemoveFileInput<'_>) -> SessionPostOutput<Remove
4952
.await
5053
}
5154

52-
#[derive(Debug)]
55+
#[derive(Debug, Clone, PartialEq)]
5356
pub struct ReadDirectoryPath {
5457
pub scope: String,
5558
}
@@ -64,7 +67,7 @@ pub async fn read_directory(
6467
.await
6568
}
6669

67-
#[derive(Debug)]
70+
#[derive(Debug, Clone, PartialEq)]
6871
pub struct CreateDirectoryPath {
6972
pub scope: String,
7073
}
@@ -79,7 +82,7 @@ pub async fn create_directory(
7982
.await
8083
}
8184

82-
#[derive(Debug)]
85+
#[derive(Debug, Clone, PartialEq)]
8386
pub struct RemoveDirectoryPath {
8487
pub scope: String,
8588
}

rust/package/src/file/models.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,45 @@ use serde::{Deserialize, Serialize};
22

33
use crate::utils::Output;
44

5-
#[derive(Serialize, Deserialize, Debug)]
5+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
66
pub struct ReadFile {
77
pub path: String,
88
}
99

10-
#[derive(Serialize, Deserialize, Debug)]
10+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
1111
pub struct WriteFile {
1212
pub path: String,
1313
pub content: Vec<u8>,
1414
}
1515

16-
#[derive(Serialize, Deserialize, Debug)]
16+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
1717
pub struct RemoveFile {
1818
pub path: String,
1919
}
2020

21-
#[derive(Serialize, Deserialize, Debug)]
21+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
2222
pub struct ReadDirectory {
2323
pub path: String,
2424
}
2525

26-
#[derive(Serialize, Deserialize, Debug)]
26+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
2727
pub struct CreateDirectory {
2828
pub path: String,
2929
pub make_parent: bool,
3030
}
3131

32-
#[derive(Serialize, Deserialize, Debug)]
32+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
3333
pub struct RemoveDirectory {
3434
pub path: String,
3535
pub make_empty: bool,
3636
}
3737

38-
#[derive(Serialize, Deserialize, Debug)]
38+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
3939
pub struct File {
4040
pub content: Output,
4141
}
4242

43-
#[derive(Serialize, Deserialize, Debug)]
43+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
4444
pub struct Directory {
4545
pub directories: Vec<String>,
4646
pub files: Vec<String>,

rust/package/src/info/models.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use serde::{Deserialize, Serialize};
22

3-
#[derive(Serialize, Deserialize)]
3+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
44
pub struct FlakeQuery {
55
pub flake: String,
66
}
77

8-
#[derive(Serialize, Deserialize)]
8+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
99
pub struct Flake {
1010
pub last_modified: u64,
1111
pub revision: String,

rust/package/src/os/models.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde::{Deserialize, Serialize};
22

3-
#[derive(Serialize, Deserialize, Debug)]
3+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
44
pub struct OSChange {
55
pub flake: Option<String>,
66
pub update_inputs: Option<Vec<String>>,
@@ -11,7 +11,7 @@ pub struct OSChange {
1111
pub user_passwd: Option<String>,
1212
}
1313

14-
#[derive(Serialize, Deserialize, Debug)]
14+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
1515
pub struct OSConfiguration {
1616
pub flake: String,
1717
pub flake_lock: String,

rust/package/src/process/handlers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub fn scope() -> String {
1111
"/process".to_string()
1212
}
1313

14+
#[derive(Debug, Clone, PartialEq)]
1415
pub struct ListPath {
1516
pub scope: String,
1617
}
@@ -23,7 +24,7 @@ pub async fn list(input: ListInput<'_>) -> SessionGetOutput<ListOutput> {
2324
.await
2425
}
2526

26-
#[derive(Debug)]
27+
#[derive(Debug, Clone, PartialEq)]
2728
pub struct LogsPath {
2829
pub scope: String,
2930
pub process: String,
@@ -41,7 +42,7 @@ pub async fn logs(input: LogsInput<'_>) -> SessionGetOutput<LogsOutput> {
4142
.await
4243
}
4344

44-
#[derive(Debug)]
45+
#[derive(Debug, Clone, PartialEq)]
4546
pub struct ExecutePath {
4647
pub scope: String,
4748
pub process: String,

0 commit comments

Comments
 (0)