notecrumbs

a nostr opengraph server build on nostrdb and egui
git clone git://jb55.com/notecrumbs
Log | Files | Refs | README | LICENSE

commit 48c7d9e8cfef67598eb67992af41a1cb46b8548d
parent c6f7eecb6e6083751151ab1a5681e8e68dfefc77
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 31 Dec 2024 09:59:52 -0800

json: add serde_json

we will need this for serializing various json stuff in our
json endpoint

Diffstat:
MCargo.lock | 1+
MCargo.toml | 1+
Msrc/error.rs | 8++++++++
3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -1618,6 +1618,7 @@ dependencies = [ "nostr", "nostr-sdk", "nostrdb", + "serde_json", "skia-safe", "tokio", "tracing", diff --git a/Cargo.toml b/Cargo.toml @@ -30,3 +30,4 @@ lru = "0.12.1" bytes = "1.5.0" http = "1.0.0" html-escape = "0.2.13" +serde_json = "*" diff --git a/src/error.rs b/src/error.rs @@ -14,6 +14,7 @@ pub enum Error { NostrClient(nostr_sdk::client::Error), Recv(RecvError), Io(std::io::Error), + Json(serde_json::Error), Generic(String), Timeout(tokio::time::error::Elapsed), Image(image::error::ImageError), @@ -44,6 +45,12 @@ impl From<http::uri::InvalidUri> for Error { } } +impl From<serde_json::Error> for Error { + fn from(err: serde_json::Error) -> Self { + Error::Json(err) + } +} + impl From<nostr_sdk::secp256k1::Error> for Error { fn from(err: nostr_sdk::secp256k1::Error) -> Self { Error::Secp(err) @@ -120,6 +127,7 @@ impl fmt::Display for Error { Error::NostrClient(e) => write!(f, "Nostr client error: {}", e), Error::NotFound => write!(f, "Not found"), Error::Recv(e) => write!(f, "Recieve error: {}", e), + Error::Json(e) => write!(f, "json error: {e}"), Error::InvalidNip19 => write!(f, "Invalid nip19 object"), Error::NothingToFetch => write!(f, "No data to fetch!"), Error::SliceErr => write!(f, "Array slice error"),