pub struct RawJson<'a>(pub Cow<'a, str>);Expand description
A raw JSON value that has not been parsed.
This type captures the raw JSON text for a value, deferring parsing until you’re ready (or skipping it entirely if you just need to pass it through).
§Example
use facet::Facet;
use facet_json::RawJson;
#[derive(Facet, Debug)]
struct Response<'a> {
status: u32,
// We don't know what shape `data` has, so defer parsing
data: RawJson<'a>,
}
let json = r#"{"status": 200, "data": {"nested": [1, 2, 3], "complex": true}}"#;
let response: Response = facet_json::from_str_borrowed(json).unwrap();
assert_eq!(response.status, 200);
assert_eq!(response.data.as_str(), r#"{"nested": [1, 2, 3], "complex": true}"#);Tuple Fields§
§0: Cow<'a, str>Implementations§
Source§impl<'a> RawJson<'a>
impl<'a> RawJson<'a>
Sourcepub fn from_owned(s: String) -> Self
pub fn from_owned(s: String) -> Self
Create a new RawJson from an owned string.
Sourcepub fn into_owned(self) -> RawJson<'static>
pub fn into_owned(self) -> RawJson<'static>
Convert into an owned RawJson<'static>.
Trait Implementations§
impl<'a> Eq for RawJson<'a>
impl<'a> StructuralPartialEq for RawJson<'a>
Auto Trait Implementations§
impl<'a> Freeze for RawJson<'a>
impl<'a> RefUnwindSafe for RawJson<'a>
impl<'a> Send for RawJson<'a>
impl<'a> Sync for RawJson<'a>
impl<'a> Unpin for RawJson<'a>
impl<'a> UnwindSafe for RawJson<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more