pub struct OperationMetadata { /* private fields */ }Expand description
Complete operation safety metadata without permissive defaults.
ⓘ
use cloud_sdk::operation::OperationMetadata;
let _: OperationMetadata = Default::default();Implementations§
Source§impl OperationMetadata
impl OperationMetadata
Sourcepub const fn new(
impact: OperationImpact,
semantics: RequestSemantics,
retry: RetryEligibility,
cost: CostIntent,
) -> Result<Self, OperationMetadataError>
pub const fn new( impact: OperationImpact, semantics: RequestSemantics, retry: RetryEligibility, cost: CostIntent, ) -> Result<Self, OperationMetadataError>
Creates complete metadata after checking safety invariants.
Examples found in repository?
examples/prepared_request.rs (lines 43-48)
31 fn prepare<'storage>(
32 &self,
33 storage: PreparationStorage<'storage>,
34 ) -> Result<PreparedRequest<'storage>, Self::Error> {
35 let (target_storage, _body_storage) = storage.into_parts();
36 let target = target_storage
37 .get_mut(..17)
38 .ok_or(PrepareError::TargetBuffer)?;
39 target.copy_from_slice(b"/resources?page=1");
40 let target = core::str::from_utf8(target).map_err(|_| PrepareError::InvalidTarget)?;
41 let target = RequestTarget::new(target).map_err(|_| PrepareError::InvalidTarget)?;
42 let request = TransportRequest::new(Method::Get, target);
43 let metadata = OperationMetadata::new(
44 OperationImpact::ReadOnly,
45 RequestSemantics::Safe,
46 RetryEligibility::ExplicitPolicy,
47 CostIntent::NoKnownCost,
48 )
49 .map_err(|_| PrepareError::InvalidMetadata)?;
50 let response_policy = ResponsePolicy::new(
51 &OK_STATUS,
52 ContentTypePolicy::Required(&JSON_MEDIA),
53 ResponseBodyPolicy::Required,
54 65_536,
55 )
56 .map_err(|_| PrepareError::InvalidResponsePolicy)?;
57 let endpoint =
58 EndpointIdentity::new(EndpointScheme::Https, "api.example.invalid", 443, "/v1")
59 .map_err(|_| PrepareError::InvalidEndpoint)?;
60 Ok(PreparedRequest::new(
61 request,
62 ProviderService::new(Provider::Hetzner, ApiFamily::Cloud, endpoint),
63 metadata,
64 response_policy,
65 ))
66 }Sourcepub const fn impact(self) -> OperationImpact
pub const fn impact(self) -> OperationImpact
Returns provider-state impact.
Sourcepub const fn semantics(self) -> RequestSemantics
pub const fn semantics(self) -> RequestSemantics
Returns HTTP request semantics.
Sourcepub const fn retry_eligibility(self) -> RetryEligibility
pub const fn retry_eligibility(self) -> RetryEligibility
Returns explicit retry eligibility.
Sourcepub const fn cost_intent(self) -> CostIntent
pub const fn cost_intent(self) -> CostIntent
Returns direct cost intent.
Trait Implementations§
Source§impl Clone for OperationMetadata
impl Clone for OperationMetadata
Source§fn clone(&self) -> OperationMetadata
fn clone(&self) -> OperationMetadata
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 Copy for OperationMetadata
Source§impl Debug for OperationMetadata
impl Debug for OperationMetadata
impl Eq for OperationMetadata
Source§impl Hash for OperationMetadata
impl Hash for OperationMetadata
Source§impl Ord for OperationMetadata
impl Ord for OperationMetadata
Source§fn cmp(&self, other: &OperationMetadata) -> Ordering
fn cmp(&self, other: &OperationMetadata) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for OperationMetadata
impl PartialEq for OperationMetadata
Source§impl PartialOrd for OperationMetadata
impl PartialOrd for OperationMetadata
impl StructuralPartialEq for OperationMetadata
Auto Trait Implementations§
impl Freeze for OperationMetadata
impl RefUnwindSafe for OperationMetadata
impl Send for OperationMetadata
impl Sync for OperationMetadata
impl Unpin for OperationMetadata
impl UnsafeUnpin for OperationMetadata
impl UnwindSafe for OperationMetadata
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