Skip to content

VersionRange additions #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2024
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