janis on Nostr: Yes, exactly! Rust lets you encode a lot more into your types than what you would ...
Yes, exactly! Rust lets you encode a lot more into your types than what you would normally be used to in other languages.
Regarding errors, if there’s semantic meaning attached to the negative ints in the API, you might want to have an Error type that captures that meaning on Rust side. Look into the thiserror crate that lets you easily spin up custom error types.
Published at
2023-12-29 15:38:43Event JSON
{
"id": "307ad9698af34ece3338fa94d65eab61d9b10a7beec0a1a07379b046ec091eac",
"pubkey": "da761b4153a1844dc03ad505fc08d125d4bb054d7cf4a4fe06de3df77a45fd85",
"created_at": 1703864323,
"kind": 1,
"tags": [
[
"e",
"1c5db59df3cf4dc451f5fa0c23bcec9fa6460667663d2d97da9729d23ce9292a"
],
[
"e",
"34591403b39f4f02e9c273c745b4e05975804d54cae6f07410ec1147499d4e92"
],
[
"p",
"9a4acdeb978565e27490dca65c83e9f65745eaec1d9a0405a52d198c1489913b"
],
[
"p",
"9a4acdeb978565e27490dca65c83e9f65745eaec1d9a0405a52d198c1489913b"
]
],
"content": "Yes, exactly! Rust lets you encode a lot more into your types than what you would normally be used to in other languages.\n\nRegarding errors, if there’s semantic meaning attached to the negative ints in the API, you might want to have an Error type that captures that meaning on Rust side. Look into the thiserror crate that lets you easily spin up custom error types.",
"sig": "520cdfa451e561a5d024c55797a4196549325e7385e588121e8564f4dcfc0567576fb2a30aecda5e76adf756826eb2327c44d809ea651f2de3f9568f54f5a34c"
}