From e15e7c98be9553004b89e6f6f29dfcaf65eb549b Mon Sep 17 00:00:00 2001 From: CookiePieWw Date: Tue, 29 Oct 2024 14:23:54 +0800 Subject: [PATCH] feat: add a function to parse jsonb only --- src/de.rs | 5 +++++ src/lib.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/de.rs b/src/de.rs index c51f77c..c3d449f 100644 --- a/src/de.rs +++ b/src/de.rs @@ -62,6 +62,11 @@ pub fn from_slice(buf: &[u8]) -> Result, Error> { } } +pub fn parse_jsonb(buf: &[u8]) -> Result, Error> { + let mut decoder = Decoder::new(buf); + decoder.decode() +} + #[repr(transparent)] pub struct Decoder<'a> { buf: &'a [u8], diff --git a/src/lib.rs b/src/lib.rs index 6e26b26..7bb3689 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,7 +79,7 @@ mod ser; mod util; mod value; -pub use de::from_slice; +pub use de::{from_slice, parse_jsonb}; pub use error::Error; #[allow(unused_imports)] pub use from::*;