Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/protocol/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Most types are used internally in encoding/decoding, and are not required by typical use cases
//! for interacting with the protocol. However, types can be used for decoding partial messages,
//! or rewriting parts of an encoded message.
use std::borrow::Borrow;
use std::cmp;
use std::collections::BTreeMap;
use std::ops::RangeBounds;
use std::{borrow::Borrow, fmt::Display};

use anyhow::{bail, Result};
use buf::{ByteBuf, ByteBufMut};
Expand Down Expand Up @@ -128,7 +128,7 @@ pub(crate) trait Decoder<Value> {
}

/// The range of versions (min, max) allowed for agiven message.
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct VersionRange {
/// The minimum version in the range.
pub min: i16,
Expand All @@ -151,6 +151,12 @@ impl VersionRange {
}
}

impl Display for VersionRange {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}..{}", self.min, self.max)
}
}

/// An API request or response.
///
/// All API messages must provide a set of valid versions.
Expand Down