Skip to content

Commit e9886e5

Browse files
Merge pull request #39 from code0-tech/21-std-runtime-function-number
Primitive Runtime Function Implementations
2 parents 028d655 + 07c3d9c commit e9886e5

8 files changed

Lines changed: 4126 additions & 244 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ tokio = { version = "1.44.1", features = ["rt-multi-thread"] }
1313
toml = "0.8.0"
1414
log = "0.4.27"
1515
futures-lite = "2.6.0"
16+
rand = "0.9.1"
17+
base64 = "0.22.1"
1618
env_logger = "0.11.8"
1719

1820
[dev-dependencies]

src/error/mod.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use std::{
44
};
55

66
#[derive(Debug, Default, Clone)]
7-
pub struct RuntimeError {}
7+
pub struct RuntimeError {
8+
name: String,
9+
message: String,
10+
suggestion: Option<String>,
11+
}
812

913
impl Error for RuntimeError {}
1014

@@ -13,3 +17,29 @@ impl Display for RuntimeError {
1317
write!(f, "&self.function_name.as_str()")
1418
}
1519
}
20+
21+
impl RuntimeError {
22+
pub fn new(name: String, message: String, suggestion: Option<String>) -> Self {
23+
Self {
24+
name,
25+
message,
26+
suggestion,
27+
}
28+
}
29+
30+
pub fn simple_str(name: &str, message: &str) -> Self {
31+
Self {
32+
name: name.to_string(),
33+
message: message.to_string(),
34+
suggestion: None,
35+
}
36+
}
37+
38+
pub fn simple(name: &str, message: String) -> Self {
39+
Self {
40+
name: name.to_string(),
41+
message: message,
42+
suggestion: None,
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)