Skip to content

Commit 4705378

Browse files
authored
Merge pull request #163 from hyperware-ai/hf/cleanup-vfs
vfs: cleanup
2 parents 5d79749 + f9582d7 commit 4705378

File tree

4 files changed

+32
-86
lines changed

4 files changed

+32
-86
lines changed

src/vfs/directory/directory_async.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/vfs/directory_async.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ pub struct DirectoryAsync {
88

99
impl DirectoryAsync {
1010
pub async fn read(&self) -> Result<Vec<DirEntry>, VfsError> {
11-
let request = vfs_request(&self.path, VfsAction::ReadDir)
12-
.expects_response(self.timeout);
11+
let request = vfs_request(&self.path, VfsAction::ReadDir).expects_response(self.timeout);
1312

1413
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
1514
.await
@@ -26,11 +25,14 @@ impl DirectoryAsync {
2625
}
2726
}
2827

29-
pub async fn open_dir_async(path: &str, create: bool, timeout: Option<u64>) -> Result<DirectoryAsync, VfsError> {
28+
pub async fn open_dir_async(
29+
path: &str,
30+
create: bool,
31+
timeout: Option<u64>,
32+
) -> Result<DirectoryAsync, VfsError> {
3033
let timeout = timeout.unwrap_or(5);
3134
if !create {
32-
let request = vfs_request(path, VfsAction::Metadata)
33-
.expects_response(timeout);
35+
let request = vfs_request(path, VfsAction::Metadata).expects_response(timeout);
3436

3537
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
3638
.await
@@ -59,8 +61,7 @@ pub async fn open_dir_async(path: &str, create: bool, timeout: Option<u64>) -> R
5961
});
6062
}
6163

62-
let request = vfs_request(path, VfsAction::CreateDirAll)
63-
.expects_response(timeout);
64+
let request = vfs_request(path, VfsAction::CreateDirAll).expects_response(timeout);
6465

6566
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
6667
.await
@@ -82,8 +83,7 @@ pub async fn open_dir_async(path: &str, create: bool, timeout: Option<u64>) -> R
8283
pub async fn remove_dir_async(path: &str, timeout: Option<u64>) -> Result<(), VfsError> {
8384
let timeout = timeout.unwrap_or(5);
8485

85-
let request = vfs_request(path, VfsAction::RemoveDir)
86-
.expects_response(timeout);
86+
let request = vfs_request(path, VfsAction::RemoveDir).expects_response(timeout);
8787

8888
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
8989
.await
@@ -97,4 +97,4 @@ pub async fn remove_dir_async(path: &str, timeout: Option<u64>) -> Result<(), Vf
9797
path: path.to_string(),
9898
}),
9999
}
100-
}
100+
}

src/vfs/file/file_async.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/vfs/file_async.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ impl FileAsync {
1818
}
1919

2020
pub async fn read(&self) -> Result<Vec<u8>, VfsError> {
21-
let request = vfs_request(&self.path, VfsAction::Read)
22-
.expects_response(self.timeout);
21+
let request = vfs_request(&self.path, VfsAction::Read).expects_response(self.timeout);
2322

2423
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
2524
.await
@@ -47,8 +46,7 @@ impl FileAsync {
4746
}
4847

4948
pub async fn read_into(&self, buffer: &mut [u8]) -> Result<usize, VfsError> {
50-
let request = vfs_request(&self.path, VfsAction::Read)
51-
.expects_response(self.timeout);
49+
let request = vfs_request(&self.path, VfsAction::Read).expects_response(self.timeout);
5250

5351
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
5452
.await
@@ -72,8 +70,8 @@ impl FileAsync {
7270
pub async fn read_at(&self, buffer: &mut [u8]) -> Result<usize, VfsError> {
7371
let length = buffer.len() as u64;
7472

75-
let request = vfs_request(&self.path, VfsAction::ReadExact { length })
76-
.expects_response(self.timeout);
73+
let request =
74+
vfs_request(&self.path, VfsAction::ReadExact { length }).expects_response(self.timeout);
7775

7876
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
7977
.await
@@ -95,8 +93,7 @@ impl FileAsync {
9593
}
9694

9795
pub async fn read_to_end(&self) -> Result<Vec<u8>, VfsError> {
98-
let request = vfs_request(&self.path, VfsAction::ReadToEnd)
99-
.expects_response(self.timeout);
96+
let request = vfs_request(&self.path, VfsAction::ReadToEnd).expects_response(self.timeout);
10097

10198
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
10299
.await
@@ -113,8 +110,8 @@ impl FileAsync {
113110
}
114111

115112
pub async fn read_to_string(&self) -> Result<String, VfsError> {
116-
let request = vfs_request(&self.path, VfsAction::ReadToString)
117-
.expects_response(self.timeout);
113+
let request =
114+
vfs_request(&self.path, VfsAction::ReadToString).expects_response(self.timeout);
118115

119116
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
120117
.await
@@ -188,8 +185,7 @@ impl FileAsync {
188185
}
189186

190187
pub async fn seek(&mut self, pos: SeekFrom) -> Result<u64, VfsError> {
191-
let request = vfs_request(&self.path, VfsAction::Seek(pos))
192-
.expects_response(self.timeout);
188+
let request = vfs_request(&self.path, VfsAction::Seek(pos)).expects_response(self.timeout);
193189

194190
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
195191
.await
@@ -234,8 +230,8 @@ impl FileAsync {
234230
}
235231

236232
pub async fn set_len(&mut self, size: u64) -> Result<(), VfsError> {
237-
let request = vfs_request(&self.path, VfsAction::SetLen(size))
238-
.expects_response(self.timeout);
233+
let request =
234+
vfs_request(&self.path, VfsAction::SetLen(size)).expects_response(self.timeout);
239235

240236
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
241237
.await
@@ -252,8 +248,7 @@ impl FileAsync {
252248
}
253249

254250
pub async fn metadata(&self) -> Result<FileMetadata, VfsError> {
255-
let request = vfs_request(&self.path, VfsAction::Metadata)
256-
.expects_response(self.timeout);
251+
let request = vfs_request(&self.path, VfsAction::Metadata).expects_response(self.timeout);
257252

258253
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
259254
.await
@@ -270,8 +265,7 @@ impl FileAsync {
270265
}
271266

272267
pub async fn sync_all(&self) -> Result<(), VfsError> {
273-
let request = vfs_request(&self.path, VfsAction::SyncAll)
274-
.expects_response(self.timeout);
268+
let request = vfs_request(&self.path, VfsAction::SyncAll).expects_response(self.timeout);
275269

276270
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
277271
.await
@@ -304,8 +298,7 @@ pub async fn create_drive_async(
304298
let timeout = timeout.unwrap_or(5);
305299
let path = format!("/{}/{}", package_id, drive);
306300

307-
let request = vfs_request(&path, VfsAction::CreateDrive)
308-
.expects_response(timeout);
301+
let request = vfs_request(&path, VfsAction::CreateDrive).expects_response(timeout);
309302

310303
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
311304
.await
@@ -321,11 +314,14 @@ pub async fn create_drive_async(
321314
}
322315
}
323316

324-
pub async fn open_file_async(path: &str, create: bool, timeout: Option<u64>) -> Result<FileAsync, VfsError> {
317+
pub async fn open_file_async(
318+
path: &str,
319+
create: bool,
320+
timeout: Option<u64>,
321+
) -> Result<FileAsync, VfsError> {
325322
let timeout = timeout.unwrap_or(5);
326323

327-
let request = vfs_request(path, VfsAction::OpenFile { create })
328-
.expects_response(timeout);
324+
let request = vfs_request(path, VfsAction::OpenFile { create }).expects_response(timeout);
329325

330326
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
331327
.await
@@ -347,8 +343,7 @@ pub async fn open_file_async(path: &str, create: bool, timeout: Option<u64>) ->
347343
pub async fn create_file_async(path: &str, timeout: Option<u64>) -> Result<FileAsync, VfsError> {
348344
let timeout = timeout.unwrap_or(5);
349345

350-
let request = vfs_request(path, VfsAction::CreateFile)
351-
.expects_response(timeout);
346+
let request = vfs_request(path, VfsAction::CreateFile).expects_response(timeout);
352347

353348
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
354349
.await
@@ -370,8 +365,7 @@ pub async fn create_file_async(path: &str, timeout: Option<u64>) -> Result<FileA
370365
pub async fn remove_file_async(path: &str, timeout: Option<u64>) -> Result<(), VfsError> {
371366
let timeout = timeout.unwrap_or(5);
372367

373-
let request = vfs_request(path, VfsAction::RemoveFile)
374-
.expects_response(timeout);
368+
let request = vfs_request(path, VfsAction::RemoveFile).expects_response(timeout);
375369

376370
let resp_bytes = hyperapp::send_rmp::<Vec<u8>>(request)
377371
.await
@@ -385,4 +379,4 @@ pub async fn remove_file_async(path: &str, timeout: Option<u64>) -> Result<(), V
385379
path: path.to_string(),
386380
}),
387381
}
388-
}
382+
}

0 commit comments

Comments
 (0)