Skip to content

Commit 687c706

Browse files
committed
Refactor into separate crates
1 parent 4f7df24 commit 687c706

File tree

11 files changed

+42
-15
lines changed

11 files changed

+42
-15
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = [
3-
"src/icfs",
3+
"crates/icfs",
4+
"crates/icfs-fatfs",
45
"examples/src/fatfs",
56
]

crates/icfs-fatfs/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "icfs-fatfs"
3+
version = "0.1.0"
4+
edition = "2018"
5+
authors = ["Paul Young <[email protected]>"]
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[lib]
10+
path = "lib.rs"
11+
12+
[dependencies]
13+
fatfs = { git = "https://github.com/rafalh/rust-fatfs", rev = "87fc1ed5074a32b4e0344fcdde77359ef9e75432" }
14+
ic-cdk = { git = "https://github.com/dfinity/cdk-rs.git", rev = "a253119adb08929b6304d007ee0a6a37960656ed" }
15+
time = "0.3"

crates/icfs-fatfs/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mod time_provider;
2+
pub use time_provider::TimeProvider;
3+

examples/src/fatfs/time_provider.rs renamed to crates/icfs-fatfs/time_provider.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use std::convert::TryInto;
22

33
#[derive(Debug, Clone, Copy, Default)]
4-
pub struct InternetComputerTimeProvider {
4+
pub struct TimeProvider {
55
_dummy: (),
66
}
77

8-
impl InternetComputerTimeProvider {
8+
impl TimeProvider {
99
#[must_use]
1010
pub fn new() -> Self {
1111
Self { _dummy: () }
1212
}
1313
}
1414

15-
impl fatfs::TimeProvider for InternetComputerTimeProvider {
15+
impl fatfs::TimeProvider for TimeProvider {
1616
fn get_current_date(&self) -> fatfs::Date {
1717
self.get_current_date_time().date
1818
}

src/icfs/Cargo.toml renamed to crates/icfs/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ authors = ["Paul Young <[email protected]>"]
88

99
[lib]
1010
path = "lib.rs"
11-
# rlib due to: https://github.com/rust-lang/cargo/issues/6659
12-
crate-type = ["cdylib", "rlib"]
1311

1412
[dependencies]
1513
ic-cdk = { git = "https://github.com/dfinity/cdk-rs.git", rev = "a253119adb08929b6304d007ee0a6a37960656ed" }

crates/icfs/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mod stable_memory;
2+
pub use stable_memory::StableMemory;
File renamed without changes.

examples/src/fatfs/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "fatfs_example"
33
version = "0.1.0"
44
edition = "2018"
5+
authors = ["Paul Young <[email protected]>"]
56

67
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
78

@@ -14,5 +15,5 @@ fatfs = { git = "https://github.com/rafalh/rust-fatfs", rev = "87fc1ed5074a32b4e
1415
fscommon = "0.1"
1516
ic-cdk = { git = "https://github.com/dfinity/cdk-rs.git", rev = "a253119adb08929b6304d007ee0a6a37960656ed" }
1617
ic-cdk-macros = "0.3"
17-
icfs = { path = "../../../src/icfs" }
18-
time = "0.3"
18+
icfs = { path = "../../../crates/icfs" }
19+
icfs-fatfs = { path = "../../../crates/icfs-fatfs" }

examples/src/fatfs/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
mod time_provider;
2-
3-
use crate::time_provider::InternetComputerTimeProvider;
41
use ic_cdk_macros::{query, update};
52
use std::io::{Read, Write};
63

@@ -9,12 +6,12 @@ use std::convert::TryInto;
96

107
// type FileSystem = fatfs::FileSystem<
118
// fatfs::StdIoWrapper<fscommon::BufStream<icfs::StableMemory>>,
12-
// InternetComputerTimeProvider,
9+
// icfs_fatfs::TimeProvider,
1310
// fatfs::LossyOemCpConverter,
1411
// >;
1512
type FileSystem = fatfs::FileSystem<
1613
fatfs::StdIoWrapper<icfs::StableMemory>,
17-
InternetComputerTimeProvider,
14+
icfs_fatfs::TimeProvider,
1815
fatfs::LossyOemCpConverter,
1916
>;
2017

@@ -47,7 +44,7 @@ thread_local! {
4744
)?;
4845

4946
let options = fatfs::FsOptions::new()
50-
.time_provider(InternetComputerTimeProvider::new())
47+
.time_provider(icfs_fatfs::TimeProvider::new())
5148
.update_accessed_date(true);
5249

5350
let fs = fatfs::FileSystem::new(stable_memory, options)?;

0 commit comments

Comments
 (0)