Skip to content

C-not exported tags for 0.0.114 #2061

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
Show file tree
Hide file tree
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: 10 additions & 0 deletions lightning/src/util/indexed_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use core::ops::{Bound, RangeBounds};
/// actually backed by a [`HashMap`], with some additional tracking to ensure we can iterate over
/// keys in the order defined by [`Ord`].
///
/// (C-not exported) as bindings provide alternate accessors rather than exposing maps directly.
///
/// [`BTreeMap`]: alloc::collections::BTreeMap
#[derive(Clone, Debug, Eq)]
pub struct IndexedMap<K: Hash + Ord, V> {
Expand Down Expand Up @@ -147,6 +149,8 @@ impl<K: Hash + Ord + PartialEq, V: PartialEq> PartialEq for IndexedMap<K, V> {
}

/// An iterator over a range of values in an [`IndexedMap`]
///
/// (C-not exported) as bindings provide alternate accessors rather than exposing maps directly.
pub struct Range<'a, K: Hash + Ord, V> {
inner_range: Iter<'a, K>,
map: &'a HashMap<K, V>,
Expand All @@ -161,6 +165,8 @@ impl<'a, K: Hash + Ord, V: 'a> Iterator for Range<'a, K, V> {
}

/// An [`Entry`] for a key which currently has no value
///
/// (C-not exported) as bindings provide alternate accessors rather than exposing maps directly.
pub struct VacantEntry<'a, K: Hash + Ord, V> {
#[cfg(feature = "hashbrown")]
underlying_entry: hash_map::VacantEntry<'a, K, V, hash_map::DefaultHashBuilder>,
Expand All @@ -171,6 +177,8 @@ pub struct VacantEntry<'a, K: Hash + Ord, V> {
}

/// An [`Entry`] for an existing key-value pair
///
/// (C-not exported) as bindings provide alternate accessors rather than exposing maps directly.
pub struct OccupiedEntry<'a, K: Hash + Ord, V> {
#[cfg(feature = "hashbrown")]
underlying_entry: hash_map::OccupiedEntry<'a, K, V, hash_map::DefaultHashBuilder>,
Expand All @@ -181,6 +189,8 @@ pub struct OccupiedEntry<'a, K: Hash + Ord, V> {

/// A mutable reference to a position in the map. This can be used to reference, add, or update the
/// value at a fixed key.
///
/// (C-not exported) as bindings provide alternate accessors rather than exposing maps directly.
pub enum Entry<'a, K: Hash + Ord, V> {
/// A mutable reference to a position within the map where there is no value.
Vacant(VacantEntry<'a, K, V>),
Expand Down
12 changes: 12 additions & 0 deletions lightning/src/util/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ impl Writer for VecWriter {

/// Writer that only tracks the amount of data written - useful if you need to calculate the length
/// of some data when serialized but don't yet need the full data.
///
/// (C-not exported) as manual TLV building is not currently supported in bindings
pub struct LengthCalculatingWriter(pub usize);
impl Writer for LengthCalculatingWriter {
#[inline]
Expand All @@ -100,6 +102,8 @@ impl Writer for LengthCalculatingWriter {

/// Essentially [`std::io::Take`] but a bit simpler and with a method to walk the underlying stream
/// forward to ensure we always consume exactly the fixed length specified.
///
/// (C-not exported) as manual TLV building is not currently supported in bindings
pub struct FixedLengthReader<R: Read> {
read: R,
bytes_read: u64,
Expand Down Expand Up @@ -155,6 +159,8 @@ impl<R: Read> LengthRead for FixedLengthReader<R> {

/// A [`Read`] implementation which tracks whether any bytes have been read at all. This allows us to distinguish
/// between "EOF reached before we started" and "EOF reached mid-read".
///
/// (C-not exported) as manual TLV building is not currently supported in bindings
pub struct ReadTrackingReader<R: Read> {
read: R,
/// Returns whether we have read from this reader or not yet.
Expand Down Expand Up @@ -289,6 +295,8 @@ impl<T: Readable> MaybeReadable for T {
}

/// Wrapper to read a required (non-optional) TLV record.
///
/// (C-not exported) as manual TLV building is not currently supported in bindings
pub struct RequiredWrapper<T>(pub Option<T>);
impl<T: Readable> Readable for RequiredWrapper<T> {
#[inline]
Expand All @@ -311,6 +319,8 @@ impl<T> From<T> for RequiredWrapper<T> {

/// Wrapper to read a required (non-optional) TLV record that may have been upgraded without
/// backwards compat.
///
/// (C-not exported) as manual TLV building is not currently supported in bindings
pub struct UpgradableRequired<T: MaybeReadable>(pub Option<T>);
impl<T: MaybeReadable> MaybeReadable for UpgradableRequired<T> {
#[inline]
Expand Down Expand Up @@ -591,6 +601,8 @@ impl Readable for [u16; 8] {

/// A type for variable-length values within TLV record where the length is encoded as part of the record.
/// Used to prevent encoding the length twice.
///
/// (C-not exported) as manual TLV building is not currently supported in bindings
pub struct WithoutLength<T>(pub T);

impl Writeable for WithoutLength<&String> {
Expand Down