pub struct TransportRequest<'a> { /* private fields */ }Expand description
Provider-neutral request passed to a blocking transport.
Implementations§
Source§impl<'a> TransportRequest<'a>
impl<'a> TransportRequest<'a>
Sourcepub const fn new(method: Method, target: RequestTarget<'a>) -> Self
pub const fn new(method: Method, target: RequestTarget<'a>) -> Self
Creates a bodyless request.
Examples found in repository?
More examples
examples/prepared_request.rs (line 57)
46 fn prepare<'storage>(
47 &self,
48 storage: PreparationStorage<'storage>,
49 ) -> Result<PreparedRequest<'storage>, Self::Error> {
50 let (target_storage, _body_storage) = storage.into_parts();
51 let target = target_storage
52 .get_mut(..17)
53 .ok_or(PrepareError::TargetBuffer)?;
54 target.copy_from_slice(b"/resources?page=1");
55 let target = core::str::from_utf8(target).map_err(|_| PrepareError::InvalidTarget)?;
56 let target = RequestTarget::new(target).map_err(|_| PrepareError::InvalidTarget)?;
57 let request = TransportRequest::new(Method::Get, target);
58 let metadata = OperationMetadata::new(
59 OperationImpact::ReadOnly,
60 RequestSemantics::Safe,
61 RetryEligibility::ExplicitPolicy,
62 CostIntent::NoKnownCost,
63 )
64 .map_err(|_| PrepareError::InvalidMetadata)?;
65 let response_policy = ResponsePolicy::new(
66 &OK_STATUS,
67 ContentTypePolicy::Required(&JSON_MEDIA),
68 ResponseBodyPolicy::Required,
69 65_536,
70 )
71 .map_err(|_| PrepareError::InvalidResponsePolicy)?;
72 let endpoint =
73 EndpointIdentity::new(EndpointScheme::Https, "api.example.invalid", 443, "/v1")
74 .map_err(|_| PrepareError::InvalidEndpoint)?;
75 Ok(PreparedRequest::new(
76 request,
77 ProviderService::from_marker::<ComputeService>(EndpointPolicy::fixed(endpoint)),
78 metadata,
79 response_policy,
80 ))
81 }Sourcepub const fn with_content_type(self, content_type: ContentType<'a>) -> Self
pub const fn with_content_type(self, content_type: ContentType<'a>) -> Self
Adds an explicit content type for the borrowed request body.
Sourcepub const fn method(self) -> Method
pub const fn method(self) -> Method
Returns the HTTP method.
Examples found in repository?
More examples
Sourcepub const fn target(self) -> RequestTarget<'a>
pub const fn target(self) -> RequestTarget<'a>
Returns the validated origin-form target.
Sourcepub const fn content_type(self) -> Option<ContentType<'a>>
pub const fn content_type(self) -> Option<ContentType<'a>>
Returns the explicit request-body content type, when configured.
Trait Implementations§
Source§impl<'a> Clone for TransportRequest<'a>
impl<'a> Clone for TransportRequest<'a>
Source§fn clone(&self) -> TransportRequest<'a>
fn clone(&self) -> TransportRequest<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for TransportRequest<'a>
Auto Trait Implementations§
impl<'a> Freeze for TransportRequest<'a>
impl<'a> RefUnwindSafe for TransportRequest<'a>
impl<'a> Send for TransportRequest<'a>
impl<'a> Sync for TransportRequest<'a>
impl<'a> Unpin for TransportRequest<'a>
impl<'a> UnsafeUnpin for TransportRequest<'a>
impl<'a> UnwindSafe for TransportRequest<'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