From 19b1b2cb903c0612c949b9ad91f6bdafba564919 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 15 Oct 2026 10:25:57 +0200 Subject: [PATCH] Re-export Value Bufany::value() returns a Value, but the type was not reachable from outside the crate, so callers could not name it or match on its variants by path. Co-Authored-By: Claude Opus 5.5 --- src/bufany.rs | 15 +++++++++++++++ src/lib.rs | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bufany.rs b/src/bufany.rs index 9459027..ec6e17d 100644 --- a/src/bufany.rs +++ b/src/bufany.rs @@ -846,6 +846,21 @@ impl<'a> Bufany<'a> { /// Gets the value of the given field number. This returns None if /// the field number does not exist + /// + /// ## Example + /// + /// ``` + /// use anybuf::{Anybuf, Bufany, Value}; + /// + /// let serialized = Anybuf::new() + /// .append_uint64(1, 150) + /// .append_string(2, "hello") + /// .into_vec(); + /// let decoded = Bufany::deserialize(&serialized).unwrap(); + /// assert_eq!(decoded.value(1), Some(Value::Varint(150))); + /// assert_eq!(decoded.value(2), Some(Value::VariableLength(b"hello"))); + /// assert_eq!(decoded.value(3), None); + /// ``` pub fn value(&self, field_number: u32) -> Option> { self.value_ref(field_number).cloned() } diff --git a/src/lib.rs b/src/lib.rs index 089bf8c..8d3f1c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,4 +37,4 @@ mod slice_reader; mod varint; pub use crate::anybuf::Anybuf; -pub use crate::bufany::{Bufany, BufanyError, RepeatedMessageError, RepeatedStringError}; +pub use crate::bufany::{Bufany, BufanyError, RepeatedMessageError, RepeatedStringError, Value};