pub enum PacketLineRef<'a> {
    Data(&'a [u8]),
    Flush,
    Delimiter,
    ResponseEnd,
}
Expand description

A borrowed packet line as it refers to a slice of data by reference.

Variants§

§

Data(&'a [u8])

A chunk of raw data.

§

Flush

A flush packet.

§

Delimiter

A delimiter packet.

§

ResponseEnd

The end of the response.

Implementations§

source§

impl<'a> PacketLineRef<'a>

source

pub fn write_to(&self, out: impl Write) -> Result<usize>

Available on crate feature blocking-io only.

Serialize this instance to out in git packetline format, returning the amount of bytes written to out.

source§

impl<'a> PacketLineRef<'a>

source

pub fn as_slice(&self) -> Option<&'a [u8]>

Return this instance as slice if it’s Data.

source

pub fn as_bstr(&self) -> Option<&'a BStr>

Return this instance’s as_slice() as BStr.

source

pub fn as_error(&self) -> Option<ErrorRef<'a>>

Interpret this instance’s as_slice() as ErrorRef.

This works for any data received in an error channel.

Note that this creates an unchecked error using the slice verbatim, which is useful to serialize it. See check_error() for a version that assures the error information is in the expected format.

source

pub fn check_error(&self) -> Option<ErrorRef<'a>>

Check this instance’s as_slice() is a valid ErrorRef and return it.

This works for any data received in an error channel.

source

pub fn as_text(&self) -> Option<TextRef<'a>>

Return this instance as text, with the trailing newline truncated if present.

source

pub fn as_band(&self, kind: Channel) -> Option<BandRef<'a>>

Interpret the data in this slice as BandRef according to the given kind of channel.

Note that this is only relevant in a side-band channel. See decode_band() in case kind is unknown.

source

pub fn decode_band(&self) -> Result<BandRef<'a>, Error>

Decode the band of this slice

Trait Implementations§

source§

impl<'a> Clone for PacketLineRef<'a>

source§

fn clone(&self) -> PacketLineRef<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for PacketLineRef<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de: 'a, 'a> Deserialize<'de> for PacketLineRef<'a>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a> Hash for PacketLineRef<'a>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> Ord for PacketLineRef<'a>

source§

fn cmp(&self, other: &PacketLineRef<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<'a> PartialEq<PacketLineRef<'a>> for PacketLineRef<'a>

source§

fn eq(&self, other: &PacketLineRef<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> PartialOrd<PacketLineRef<'a>> for PacketLineRef<'a>

source§

fn partial_cmp(&self, other: &PacketLineRef<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a> Serialize for PacketLineRef<'a>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a> Copy for PacketLineRef<'a>

source§

impl<'a> Eq for PacketLineRef<'a>

source§

impl<'a> StructuralEq for PacketLineRef<'a>

source§

impl<'a> StructuralPartialEq for PacketLineRef<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for PacketLineRef<'a>

§

impl<'a> Send for PacketLineRef<'a>

§

impl<'a> Sync for PacketLineRef<'a>

§

impl<'a> Unpin for PacketLineRef<'a>

§

impl<'a> UnwindSafe for PacketLineRef<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,