Skip to content

Commit

Permalink
feat(quinn-proto): unhide quinn_proto::coding
Browse files Browse the repository at this point in the history
It turned out currently the `coding` mod is already public, simply hidden from the docs.

It seems to be the minimal change to allow using this functionality for `VarInt` is to document it and not hide it.

Fixes #1277
  • Loading branch information
dignifiedquire authored and djc committed Dec 12, 2024
1 parent 204b147 commit 7647bd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 9 additions & 2 deletions quinn-proto/src/coding.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
//! Coding related traits.
use std::net::{Ipv4Addr, Ipv6Addr};

use bytes::{Buf, BufMut};
use thiserror::Error;

use crate::VarInt;

/// Error indicating that the provided buffer was too small
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
#[error("unexpected end of buffer")]
pub struct UnexpectedEnd;

/// Coding result type
pub type Result<T> = ::std::result::Result<T, UnexpectedEnd>;

/// Infallible encoding and decoding of QUIC primitives
pub trait Codec: Sized {
/// Decode a `Self` from the provided buffer, if the buffer is large enough
fn decode<B: Buf>(buf: &mut B) -> Result<Self>;
/// Append the encoding of `self` to the provided buffer
fn encode<B: BufMut>(&self, buf: &mut B);
}

Expand Down Expand Up @@ -92,7 +99,7 @@ impl Codec for Ipv6Addr {
}
}

pub trait BufExt {
pub(crate) trait BufExt {
fn get<T: Codec>(&mut self) -> Result<T>;
fn get_var(&mut self) -> Result<u64>;
}
Expand All @@ -107,7 +114,7 @@ impl<T: Buf> BufExt for T {
}
}

pub trait BufMutExt {
pub(crate) trait BufMutExt {
fn write<T: Codec>(&mut self, x: T);
fn write_var(&mut self, x: u64);
}
Expand Down
1 change: 0 additions & 1 deletion quinn-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::{
};

mod cid_queue;
#[doc(hidden)]
pub mod coding;
mod constant_time;
mod range_set;
Expand Down

0 comments on commit 7647bd0

Please sign in to comment.