pub enum Body {
Json(Value),
Text(String),
}Expand description
What the recorder writes when a body is not valid JSON. The cassette stays a JSON document, so a non-JSON body (an HTML error page from a proxy, a truncated stream) is preserved as text rather than dropped or allowed to fail the capture.
Variants§
Json(Value)
A parsed JSON body — the normal case for a provider API.
Text(String)
A body that did not parse as JSON, preserved verbatim.
Implementations§
Source§impl Body
impl Body
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Parse captured bytes into a body, falling back to lossy text.
Capture never fails on a malformed body: a recording that dies because the provider
returned an HTML 502 is a recording you cannot debug, which is exactly when you needed
it. The fidelity loss is reported by shape (Text rather than Json), not hidden.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Body
impl<'de> Deserialize<'de> for Body
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Body
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnsafeUnpin for Body
impl UnwindSafe for Body
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