Style fixes

This commit is contained in:
QuantumEntangledAndy committed 2024-10-26 14:33:19 +07:00
1 parent 4f8fb6c7b5
commit ed4a5ea001
9 files changed
+13 -57

No files matched your search

+2 -4
View File
@@ -90,10 +90,8 @@ fn bc_modern_msg<'a>(
E::add_context(input, ctx, E::from_error_kind(input, kind))
}
let ext_len = match header.payload_offset {
Some(off) => off,
_ => 0, // If missing payload_offset treat all as payload
};
// If missing payload_offset treat all as payload
let ext_len = header.payload_offset.unwrap_or_default();
let (buf, ext_buf) = take(ext_len)(buf)?;
let payload_len = header.body_len - ext_len;
+3 -8
View File
@@ -192,8 +192,11 @@ pub struct BcMeta {
pub stream_type: u8,
/// On modern messages this is the response code
/// When sending a command it is set to `0`. The reply from the camera can be
///
/// - `200` for OK
///
/// - `400` for bad request
///
/// A malformed packet will return a `400` code
pub response_code: u16,
/// A message ID is used to match replies with requests. The camera will parrot back
@@ -213,14 +216,6 @@ pub struct BcMeta {
pub class: u16,
}
/// The components of the Baichuan header that must be filled out after the body is serialized, or
/// is needed for the deserialization of the body (strictly part of the wire format of the message)
#[derive(Debug, PartialEq, Eq)]
pub(super) struct BcSendInfo {
pub body_len: u32,
pub payload_offset: Option<u32>,
}
#[derive(Debug)]
pub(crate) struct BcContext {
pub(crate) credentials: Credentials,
@@ -20,9 +20,9 @@ pub struct BcStream<'a> {
rx: &'a mut ReceiverStream<Result<Bc>>,
}
impl<'a> Unpin for BcStream<'a> {}
impl Unpin for BcStream<'_> {}
impl<'a> Stream for BcStream<'a> {
impl Stream for BcStream<'_> {
type Item = Result<Bc>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bc>>> {
+1 -1
View File
@@ -214,7 +214,7 @@ impl ToSocketAddrsOrUid for SocketAddrV6 {
}
}
impl<'a> ToSocketAddrsOrUid for &'a [SocketAddr] {
impl ToSocketAddrsOrUid for &'_ [SocketAddr] {
type UidIter = std::vec::IntoIter<SocketAddrOrUid>;
fn to_socket_addrs_or_uid(&self) -> Result<Self::UidIter, Error> {
-9
View File
@@ -34,15 +34,6 @@ impl Decoder for BcUdpCodex {
type Item = BcUdp;
type Error = Error;
/// Since frames can cross EOF boundaries we overload this so it doesn't error if
/// there are bytes left on the stream
// fn decode_eof(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>> {
// match self.decode(buf)? {
// Some(frame) => Ok(Some(frame)),
// None => Ok(None),
// }
// }
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>> {
log::trace!("Decoding:");
if src.is_empty() {