pub enum Body {
Plain(String),
Typed {
body_type: String,
json: String,
},
File {
file_path: String,
content_type: Option<String>,
template_type: Option<String>,
},
}Expand description
Request/response body — either a plain string, a typed object, or a file reference.
Variants§
Plain(String)
A plain string body.
Typed
A typed body (e.g., JSON).
File
A file body (type: "FILE"), with optional template evaluation.
Implementations§
Source§impl Body
impl Body
Sourcepub fn file(file_path: impl Into<String>) -> Self
pub fn file(file_path: impl Into<String>) -> Self
Create a FILE body referencing a path on the server filesystem.
§Example
use mockserver_client::Body;
let body = Body::file("/data/response.json")
.with_content_type("application/json")
.with_template_type("VELOCITY");Sourcepub fn with_content_type(self, content_type: impl Into<String>) -> Self
pub fn with_content_type(self, content_type: impl Into<String>) -> Self
Set the content type on a FILE body. No-op on other variants.
Sourcepub fn with_template_type(self, template_type: impl Into<String>) -> Self
pub fn with_template_type(self, template_type: impl Into<String>) -> Self
Set the template type (e.g., “VELOCITY”, “MUSTACHE”) on a FILE body. No-op on other variants.
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