Skip to content

Commit 54c979a

Browse files
committed
chore: use one error
1 parent 34a79a3 commit 54c979a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+727
-1982
lines changed

Cargo.lock

Lines changed: 0 additions & 141 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile.toml

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -76,45 +76,3 @@ default_to_workspace = false
7676

7777
[env]
7878
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
79-
80-
[tasks.wasm_build]
81-
script_runner = "bash"
82-
script = [
83-
"""
84-
#!/bin/bash
85-
BASE_DIR=$(pwd)
86-
crates=("collab")
87-
88-
# Iterate over each crate and build it
89-
for crate in "${crates[@]}"; do
90-
echo "🔥🔥🔥 Building $crate with wasm-pack..."
91-
92-
# Navigate to the crate directory
93-
cd "$BASE_DIR/$crate" || { echo "Failed to enter directory $crate"; exit 1; }
94-
95-
# Build the crate
96-
wasm-pack build || { echo "Build failed for $crate"; exit 1; }
97-
done
98-
"""
99-
]
100-
101-
[tasks.wasm_test]
102-
script_runner = "bash"
103-
script = [
104-
"""
105-
#!/bin/bash
106-
BASE_DIR=$(pwd)
107-
crates=("collab")
108-
109-
# Iterate over each crate and build it
110-
for crate in "${crates[@]}"; do
111-
echo "🔥🔥🔥 Running $crate tests with wasm-pack..."
112-
113-
# Navigate to the crate directory
114-
cd "$BASE_DIR/$crate" || { echo "Failed to enter directory $crate"; exit 1; }
115-
116-
# Build the crate
117-
wasm-pack test --headless --firefox
118-
done
119-
"""
120-
]

collab/Cargo.toml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,7 @@ async-recursion = "1.1"
5858
sanitize-filename = "0.5.0"
5959
indexmap = { version = "2.3", features = ["serde"] }
6060
zip = "0.6.6"
61-
62-
[target.'cfg(target_arch = "wasm32")'.dependencies]
63-
web-sys = { version = "0.3" }
64-
js-sys = "0.3"
65-
getrandom = { version = "0.2", features = ["js"] }
66-
indexed_db_futures = { version = "0.4" }
67-
async-stream = "0.3"
68-
wasm-bindgen = "0.2"
69-
wasm-bindgen-futures = "0.4"
70-
tracing-wasm = "0.2"
61+
rocksdb = { version = "0.22.0", default-features = false, features = ["zstd"], optional = true }
7162

7263
[dev-dependencies]
7364
tokio = { workspace = true, features = ["macros", "sync", "rt"] }
@@ -93,6 +84,3 @@ import_csv = []
9384
[build-dependencies]
9485
prost-build = "0.12"
9586
protoc-bin-vendored = "3.0.0"
96-
97-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
98-
rocksdb = { version = "0.22.0", default-features = false, features = ["zstd"], optional = true }

collab/src/core/fill.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1+
use crate::error::CollabError;
12
use crate::util::ArrayExt;
23

34
use yrs::types::TypeRef;
45
use yrs::{Any, Array, ArrayPrelim, ArrayRef, Map, MapPrelim, MapRef, SharedRef, TransactionMut};
56

6-
#[derive(Debug, thiserror::Error)]
7-
pub enum FillError {
8-
#[error("cannot fill {0} with: {0}")]
9-
InvalidData(TypeRef, String),
10-
}
11-
127
/// Trait that allows to fill shared refs with data.
138
pub trait FillRef<R>
149
where
1510
R: SharedRef,
1611
{
17-
fn fill(self, txn: &mut TransactionMut, shared_ref: &R) -> Result<(), FillError>;
12+
fn fill(self, txn: &mut TransactionMut, shared_ref: &R) -> Result<(), CollabError>;
1813
}
1914

2015
impl FillRef<MapRef> for Any {
21-
fn fill(self, txn: &mut TransactionMut, shared_ref: &MapRef) -> Result<(), FillError> {
16+
fn fill(self, txn: &mut TransactionMut, shared_ref: &MapRef) -> Result<(), CollabError> {
2217
match self {
2318
Any::Map(map) => {
2419
for (key, value) in map.iter() {
@@ -40,13 +35,13 @@ impl FillRef<MapRef> for Any {
4035
}
4136
Ok(())
4237
},
43-
_ => Err(FillError::InvalidData(TypeRef::Map, self.to_string())),
38+
_ => Err(CollabError::FillInvalidData(TypeRef::Map, self.to_string())),
4439
}
4540
}
4641
}
4742

4843
impl FillRef<ArrayRef> for Any {
49-
fn fill(self, txn: &mut TransactionMut, shared_ref: &ArrayRef) -> Result<(), FillError> {
44+
fn fill(self, txn: &mut TransactionMut, shared_ref: &ArrayRef) -> Result<(), CollabError> {
5045
match self {
5146
Any::Array(array) => {
5247
shared_ref.clear(txn);
@@ -56,7 +51,10 @@ impl FillRef<ArrayRef> for Any {
5651
}
5752
Ok(())
5853
},
59-
_ => Err(FillError::InvalidData(TypeRef::Array, self.to_string())),
54+
_ => Err(CollabError::FillInvalidData(
55+
TypeRef::Array,
56+
self.to_string(),
57+
)),
6058
}
6159
}
6260
}

0 commit comments

Comments
 (0)