pub struct Patch {
pub unit: String,
pub range: String,
pub content: Bytes,
pub content_length: Option<usize>,
}Expand description
A patch representing a partial update to a resource.
Fields§
§unit: StringThe addressing unit type (e.g., "json", "bytes")
range: StringThe range specification
content: BytesThe patch content
content_length: Option<usize>Content length in bytes
Implementations§
Source§impl Patch
impl Patch
Sourcepub fn new(
unit: impl Into<String>,
range: impl Into<String>,
content: impl Into<Bytes>,
) -> Self
pub fn new( unit: impl Into<String>, range: impl Into<String>, content: impl Into<Bytes>, ) -> Self
Create a new patch.
pub fn json(range: impl Into<String>, content: impl Into<Bytes>) -> Self
pub fn bytes(range: impl Into<String>, content: impl Into<Bytes>) -> Self
pub fn text(range: impl Into<String>, content: impl Into<String>) -> Self
pub fn lines(range: impl Into<String>, content: impl Into<String>) -> Self
pub fn with_length( unit: impl Into<String>, range: impl Into<String>, content: impl Into<Bytes>, length: usize, ) -> Self
pub fn is_json(&self) -> bool
pub fn is_bytes(&self) -> bool
pub fn is_text(&self) -> bool
pub fn is_lines(&self) -> bool
pub fn content_str(&self) -> Option<&str>
pub fn content_text(&self) -> Option<&str>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn content_range_header(&self) -> String
pub fn validate(&self) -> Result<()>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Patch
impl<'de> Deserialize<'de> for Patch
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 Eq for Patch
impl StructuralPartialEq for Patch
Auto Trait Implementations§
impl !Freeze for Patch
impl RefUnwindSafe for Patch
impl Send for Patch
impl Sync for Patch
impl Unpin for Patch
impl UnwindSafe for Patch
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
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
Compare self to
key and return true if they are equal.