azure_core/request_options/if_sequence_number.rs
1use crate::{headers, Header};
2
3/// Conditional request header based on the value of the object's sequence number
4///
5/// Ref: <https://docs.microsoft.com/en-us/rest/api/storageservices/put-page-from-url>
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum IfSequenceNumber {
8 /// If the object's sequence number is less than the specified value, the
9 /// request proceeds; otherwise it fails with SequenceNumberConditionNotMet
10 /// error (HTTP status code 412 – Precondition Failed).
11 LessThan(u64),
12 /// If the object's sequence number is less than or equal to the specified
13 /// value, the request proceeds; otherwise it fails with the
14 /// SequenceNumberConditionNotMet error (HTTP status code 412 – Precondition
15 /// Failed).
16 LessOrEqual(u64),
17 /// If the object’s sequence number is equal to the specified value, the
18 /// request proceeds; otherwise it fails with SequenceNumberConditionNotMet
19 /// error (HTTP status code 412 – Precondition Failed).
20 Equal(u64),
21}
22
23impl Header for IfSequenceNumber {
24 fn name(&self) -> headers::HeaderName {
25 match self {
26 IfSequenceNumber::Equal(_) => headers::IF_SEQUENCE_NUMBER_EQ,
27 IfSequenceNumber::LessOrEqual(_) => headers::IF_SEQUENCE_NUMBER_LE,
28 IfSequenceNumber::LessThan(_) => headers::IF_SEQUENCE_NUMBER_LT,
29 }
30 }
31
32 fn value(&self) -> headers::HeaderValue {
33 match self {
34 IfSequenceNumber::Equal(val)
35 | IfSequenceNumber::LessOrEqual(val)
36 | IfSequenceNumber::LessThan(val) => val.to_string().into(),
37 }
38 }
39}