pub struct Call {
pub operation: &'static str,
pub method: Method,
pub path: String,
pub body: Option<Vec<u8>>,
}Expand description
One control-plane call: method, path, optional JSON body.
A struct rather than a long parameter list because the recorder asserts on it as a
whole, and because method and path next to each other is how a reader checks a
path against the model’s http trait.
Fields§
§operation: &'static strThe operation name, for diagnostics and for the recorder’s ledger.
Carried rather than derived from the path: the recorder’s TRAP-11 assertion is
“an exec lifecycle emits no call named CreateMicrovmShellAuthToken”, and
matching that on a path is a substring test that a renamed route would slip past.
method: MethodGET, POST, PATCH, or DELETE — the four the model’s http traits use for the
operations this client implements.
path: StringThe path after the host, with the API version and every URI parameter already percent-encoded. Includes the query string when the operation has one.
body: Option<Vec<u8>>The rest-json body, or None for an operation the model gives no body members.
Implementations§
Source§impl Call
impl Call
Sourcepub fn post_json<T: Serialize>(
operation: &'static str,
path: impl Into<String>,
body: &T,
) -> Result<Self, Error>
pub fn post_json<T: Serialize>( operation: &'static str, path: impl Into<String>, body: &T, ) -> Result<Self, Error>
A POST carrying a serialized rest-json body.
Sourcepub fn patch_json<T: Serialize>(
operation: &'static str,
path: impl Into<String>,
body: &T,
) -> Result<Self, Error>
pub fn patch_json<T: Serialize>( operation: &'static str, path: impl Into<String>, body: &T, ) -> Result<Self, Error>
A PATCH carrying a serialized rest-json body.
The same shape as Call::post_json and written beside it rather than folded into a
method-taking constructor, for the reason Method’s docs give: the method is part of
the route the model declares, and a with_method(Method::Patch) builder is one a call
site can forget to call. UpdateMicrovmImageVersion is the only operation that reaches
this.
Sourcepub fn post_empty(operation: &'static str, path: impl Into<String>) -> Self
pub fn post_empty(operation: &'static str, path: impl Into<String>) -> Self
A POST with no body members. SuspendMicrovm and ResumeMicrovm are both this
shape: their only member is the URI-located identifier.
The body is Some(b"{}") rather than None, because an empty POST and a POST of
{} are different canonical requests and rest-json services answer the former
inconsistently.
Sourcepub fn body_bytes(&self) -> &[u8] ⓘ
pub fn body_bytes(&self) -> &[u8] ⓘ
The body as bytes, empty when there is none — which is what gets signed.
Trait Implementations§
impl Eq for Call
impl StructuralPartialEq for Call
Auto Trait Implementations§
impl Freeze for Call
impl RefUnwindSafe for Call
impl Send for Call
impl Sync for Call
impl Unpin for Call
impl UnsafeUnpin for Call
impl UnwindSafe for Call
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.