Skip to content

Commit c07bde9

Browse files
committed
rename
1 parent 58292fb commit c07bde9

File tree

3 files changed

+52
-52
lines changed

3 files changed

+52
-52
lines changed

src/error.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum ErrorKind {
2727
UriParts(uri::InvalidUriParts),
2828
HeaderName(header::InvalidHeaderName),
2929
HeaderValue(header::InvalidHeaderValue),
30-
CapacityOverflow(CapacityOverflow),
30+
MaxSizeReached(MaxSizeReached),
3131
}
3232

3333
impl fmt::Debug for Error {
@@ -62,7 +62,7 @@ impl Error {
6262
UriParts(ref e) => e,
6363
HeaderName(ref e) => e,
6464
HeaderValue(ref e) => e,
65-
CapacityOverflow(ref e) => e,
65+
MaxSizeReached(ref e) => e,
6666
}
6767
}
6868
}
@@ -75,10 +75,10 @@ impl error::Error for Error {
7575
}
7676
}
7777

78-
impl From<CapacityOverflow> for Error {
79-
fn from(err: CapacityOverflow) -> Error {
78+
impl From<MaxSizeReached> for Error {
79+
fn from(err: MaxSizeReached) -> Error {
8080
Error {
81-
inner: ErrorKind::CapacityOverflow(err),
81+
inner: ErrorKind::MaxSizeReached(err),
8282
}
8383
}
8484
}
@@ -138,32 +138,32 @@ impl From<std::convert::Infallible> for Error {
138138
}
139139

140140
/// Error returned when max capacity of `HeaderMap` is exceeded
141-
pub struct CapacityOverflow {
141+
pub struct MaxSizeReached {
142142
_priv: (),
143143
}
144144

145-
impl CapacityOverflow {
146-
/// Create new `CapacityOverflow` instance
147-
pub fn new() -> CapacityOverflow {
148-
CapacityOverflow { _priv: () }
145+
impl MaxSizeReached {
146+
/// Create new `MaxSizeReached` instance
147+
pub fn new() -> MaxSizeReached {
148+
MaxSizeReached { _priv: () }
149149
}
150150
}
151151

152-
impl fmt::Debug for CapacityOverflow {
152+
impl fmt::Debug for MaxSizeReached {
153153
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
154-
f.debug_struct("CapacityOverflow")
154+
f.debug_struct("MaxSizeReached")
155155
// skip _priv noise
156156
.finish()
157157
}
158158
}
159159

160-
impl fmt::Display for CapacityOverflow {
160+
impl fmt::Display for MaxSizeReached {
161161
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
162-
f.write_str("failed to allocate for additional header")
162+
f.write_str("max capacity reached")
163163
}
164164
}
165165

166-
impl std::error::Error for CapacityOverflow {}
166+
impl std::error::Error for MaxSizeReached {}
167167

168168

169169
#[cfg(test)]

src/header/map.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::marker::PhantomData;
77
use std::{fmt, mem, ops, ptr, vec};
88

99
use crate::Error;
10-
use crate::error::CapacityOverflow;
10+
use crate::error::MaxSizeReached;
1111

1212
use super::HeaderValue;
1313
use super::name::{HdrName, HeaderName};
@@ -489,7 +489,7 @@ impl<T> HeaderMap<T> {
489489
/// assert!(map.is_empty());
490490
/// assert_eq!(12, map.capacity());
491491
/// ```
492-
pub fn try_with_capacity(capacity: usize) -> Result<HeaderMap<T>, CapacityOverflow> {
492+
pub fn try_with_capacity(capacity: usize) -> Result<HeaderMap<T>, MaxSizeReached> {
493493
if capacity == 0 {
494494
Ok(HeaderMap {
495495
mask: 0,
@@ -501,7 +501,7 @@ impl<T> HeaderMap<T> {
501501
} else {
502502
let raw_cap = to_raw_capacity(capacity).next_power_of_two();
503503
if raw_cap > MAX_SIZE {
504-
return Err(CapacityOverflow::new());
504+
return Err(MaxSizeReached::new());
505505
}
506506
debug_assert!(raw_cap > 0);
507507

@@ -686,19 +686,19 @@ impl<T> HeaderMap<T> {
686686
/// map.try_reserve(10).unwrap();
687687
/// # map.try_insert(HOST, "bar".parse().unwrap()).unwrap();
688688
/// ```
689-
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CapacityOverflow> {
689+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), MaxSizeReached> {
690690
// TODO: This can't overflow if done properly... since the max # of
691691
// elements is u16::MAX.
692692
let cap = self
693693
.entries
694694
.len()
695695
.checked_add(additional)
696-
.ok_or_else(|| CapacityOverflow::new())?;
696+
.ok_or_else(|| MaxSizeReached::new())?;
697697

698698
if cap > self.indices.len() {
699-
let cap = cap.checked_next_power_of_two().ok_or_else(|| CapacityOverflow::new())?;
699+
let cap = cap.checked_next_power_of_two().ok_or_else(|| MaxSizeReached::new())?;
700700
if cap > MAX_SIZE {
701-
return Err(CapacityOverflow::new());
701+
return Err(MaxSizeReached::new());
702702
}
703703

704704
if self.entries.len() == 0 {
@@ -1123,7 +1123,7 @@ impl<T> HeaderMap<T> {
11231123
/// do not parse as a valid `HeaderName`, this returns an
11241124
/// `InvalidHeaderName` error.
11251125
///
1126-
/// It may return `CapacityOverflow` error if size exceeds the maximum
1126+
/// It may return `MaxSizeReached` error if size exceeds the maximum
11271127
/// `HeaderMap` capacity
11281128
pub fn try_entry<K>(&mut self, key: K) -> Result<Entry<'_, T>, Error>
11291129
where
@@ -1132,7 +1132,7 @@ impl<T> HeaderMap<T> {
11321132
key.try_entry(self)
11331133
}
11341134

1135-
fn try_entry2<K>(&mut self, key: K) -> Result<Entry<'_, T>, CapacityOverflow>
1135+
fn try_entry2<K>(&mut self, key: K) -> Result<Entry<'_, T>, MaxSizeReached>
11361136
where
11371137
K: Hash + Into<HeaderName>,
11381138
HeaderName: PartialEq<K>,
@@ -1234,15 +1234,15 @@ impl<T> HeaderMap<T> {
12341234
/// let mut prev = map.try_insert(HOST, "earth".parse().unwrap()).unwrap().unwrap();
12351235
/// assert_eq!("world", prev);
12361236
/// ```
1237-
pub fn try_insert<K>(&mut self, key: K, val: T) -> Result<Option<T>, CapacityOverflow>
1237+
pub fn try_insert<K>(&mut self, key: K, val: T) -> Result<Option<T>, MaxSizeReached>
12381238
where
12391239
K: IntoHeaderName,
12401240
{
12411241
key.try_insert(self, val)
12421242
}
12431243

12441244
#[inline]
1245-
fn try_insert2<K>(&mut self, key: K, value: T) -> Result<Option<T>, CapacityOverflow>
1245+
fn try_insert2<K>(&mut self, key: K, value: T) -> Result<Option<T>, MaxSizeReached>
12461246
where
12471247
K: Hash + Into<HeaderName>,
12481248
HeaderName: PartialEq<K>,
@@ -1374,15 +1374,15 @@ impl<T> HeaderMap<T> {
13741374
/// assert_eq!("world", *i.next().unwrap());
13751375
/// assert_eq!("earth", *i.next().unwrap());
13761376
/// ```
1377-
pub fn try_append<K>(&mut self, key: K, value: T) -> Result<bool, CapacityOverflow>
1377+
pub fn try_append<K>(&mut self, key: K, value: T) -> Result<bool, MaxSizeReached>
13781378
where
13791379
K: IntoHeaderName,
13801380
{
13811381
key.try_append(self, value)
13821382
}
13831383

13841384
#[inline]
1385-
fn try_append2<K>(&mut self, key: K, value: T) -> Result<bool, CapacityOverflow>
1385+
fn try_append2<K>(&mut self, key: K, value: T) -> Result<bool, MaxSizeReached>
13861386
where
13871387
K: Hash + Into<HeaderName>,
13881388
HeaderName: PartialEq<K>,
@@ -1458,7 +1458,7 @@ impl<T> HeaderMap<T> {
14581458
hash: HashValue,
14591459
probe: usize,
14601460
danger: bool,
1461-
) -> Result<usize, CapacityOverflow> {
1461+
) -> Result<usize, MaxSizeReached> {
14621462
// Push the value and get the index
14631463
let index = self.entries.len();
14641464
self.try_insert_entry(hash, key, value)?;
@@ -1592,9 +1592,9 @@ impl<T> HeaderMap<T> {
15921592
}
15931593

15941594
#[inline]
1595-
fn try_insert_entry(&mut self, hash: HashValue, key: HeaderName, value: T) -> Result<(), CapacityOverflow> {
1595+
fn try_insert_entry(&mut self, hash: HashValue, key: HeaderName, value: T) -> Result<(), MaxSizeReached> {
15961596
if self.entries.len() >= MAX_SIZE {
1597-
return Err(CapacityOverflow::new());
1597+
return Err(MaxSizeReached::new());
15981598
}
15991599

16001600
self.entries.push(Bucket {
@@ -1654,7 +1654,7 @@ impl<T> HeaderMap<T> {
16541654
}
16551655
}
16561656

1657-
fn try_reserve_one(&mut self) -> Result<(), CapacityOverflow> {
1657+
fn try_reserve_one(&mut self) -> Result<(), MaxSizeReached> {
16581658
let len = self.entries.len();
16591659

16601660
if self.danger.is_yellow() {
@@ -1695,9 +1695,9 @@ impl<T> HeaderMap<T> {
16951695
}
16961696

16971697
#[inline]
1698-
fn try_grow(&mut self, new_raw_cap: usize) -> Result<(), CapacityOverflow> {
1698+
fn try_grow(&mut self, new_raw_cap: usize) -> Result<(), MaxSizeReached> {
16991699
if new_raw_cap > MAX_SIZE {
1700-
return Err(CapacityOverflow::new());
1700+
return Err(MaxSizeReached::new());
17011701
}
17021702

17031703
// find first ideally placed element -- start of cluster
@@ -2472,7 +2472,7 @@ impl<'a, T> Entry<'a, T> {
24722472
/// assert_eq!(map["content-length"], 2);
24732473
/// assert_eq!(map["x-hello"], 1);
24742474
/// ```
2475-
pub fn or_try_insert(self, default: T) -> Result<&'a mut T, CapacityOverflow> {
2475+
pub fn or_try_insert(self, default: T) -> Result<&'a mut T, MaxSizeReached> {
24762476
use self::Entry::*;
24772477

24782478
match self {
@@ -2557,7 +2557,7 @@ impl<'a, T> Entry<'a, T> {
25572557
///
25582558
/// assert_eq!(res, "world");
25592559
/// ```
2560-
pub fn or_try_insert_with<F: FnOnce() -> T>(self, default: F) -> Result<&'a mut T, CapacityOverflow> {
2560+
pub fn or_try_insert_with<F: FnOnce() -> T>(self, default: F) -> Result<&'a mut T, MaxSizeReached> {
25612561
use self::Entry::*;
25622562

25632563
match self {
@@ -2657,7 +2657,7 @@ impl<'a, T> VacantEntry<'a, T> {
26572657
///
26582658
/// assert_eq!(map["x-hello"], "world");
26592659
/// ```
2660-
pub fn try_insert(self, value: T) -> Result<&'a mut T, CapacityOverflow> {
2660+
pub fn try_insert(self, value: T) -> Result<&'a mut T, MaxSizeReached> {
26612661
// Ensure that there is space in the map
26622662
let index =
26632663
self.map
@@ -2706,7 +2706,7 @@ impl<'a, T> VacantEntry<'a, T> {
27062706
///
27072707
/// assert_eq!(map["x-hello"], "world2");
27082708
/// ```
2709-
pub fn try_insert_entry(self, value: T) -> Result<OccupiedEntry<'a, T>, CapacityOverflow> {
2709+
pub fn try_insert_entry(self, value: T) -> Result<OccupiedEntry<'a, T>, MaxSizeReached> {
27102710
// Ensure that there is space in the map
27112711
let index =
27122712
self.map
@@ -3534,7 +3534,7 @@ where
35343534
*/
35353535

35363536
mod into_header_name {
3537-
use crate::error::CapacityOverflow;
3537+
use crate::error::MaxSizeReached;
35383538
use super::{Entry, HdrName, HeaderMap, HeaderName};
35393539

35403540
/// A marker trait used to identify values that can be used as insert keys
@@ -3551,30 +3551,30 @@ mod into_header_name {
35513551
// without breaking any external crate.
35523552
pub trait Sealed {
35533553
#[doc(hidden)]
3554-
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, CapacityOverflow>;
3554+
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, MaxSizeReached>;
35553555

35563556
#[doc(hidden)]
3557-
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, CapacityOverflow>;
3557+
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, MaxSizeReached>;
35583558

35593559
#[doc(hidden)]
3560-
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, CapacityOverflow>;
3560+
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, MaxSizeReached>;
35613561
}
35623562

35633563
// ==== impls ====
35643564

35653565
impl Sealed for HeaderName {
35663566
#[inline]
3567-
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, CapacityOverflow> {
3567+
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, MaxSizeReached> {
35683568
map.try_insert2(self, val)
35693569
}
35703570

35713571
#[inline]
3572-
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, CapacityOverflow> {
3572+
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, MaxSizeReached> {
35733573
map.try_append2(self, val)
35743574
}
35753575

35763576
#[inline]
3577-
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, CapacityOverflow> {
3577+
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, MaxSizeReached> {
35783578
map.try_entry2(self)
35793579
}
35803580
}
@@ -3583,16 +3583,16 @@ mod into_header_name {
35833583

35843584
impl<'a> Sealed for &'a HeaderName {
35853585
#[inline]
3586-
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, CapacityOverflow> {
3586+
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, MaxSizeReached> {
35873587
map.try_insert2(self, val)
35883588
}
35893589
#[inline]
3590-
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, CapacityOverflow> {
3590+
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, MaxSizeReached> {
35913591
map.try_append2(self, val)
35923592
}
35933593

35943594
#[inline]
3595-
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, CapacityOverflow> {
3595+
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, MaxSizeReached> {
35963596
map.try_entry2(self)
35973597
}
35983598
}
@@ -3601,16 +3601,16 @@ mod into_header_name {
36013601

36023602
impl Sealed for &'static str {
36033603
#[inline]
3604-
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, CapacityOverflow> {
3604+
fn try_insert<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<Option<T>, MaxSizeReached> {
36053605
HdrName::from_static(self, move |hdr| map.try_insert2(hdr, val))
36063606
}
36073607
#[inline]
3608-
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, CapacityOverflow> {
3608+
fn try_append<T>(self, map: &mut HeaderMap<T>, val: T) -> Result<bool, MaxSizeReached> {
36093609
HdrName::from_static(self, move |hdr| map.try_append2(hdr, val))
36103610
}
36113611

36123612
#[inline]
3613-
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, CapacityOverflow>{
3613+
fn try_entry<T>(self, map: &mut HeaderMap<T>) -> Result<Entry<'_, T>, MaxSizeReached>{
36143614
HdrName::from_static(self, move |hdr| map.try_entry2(hdr))
36153615
}
36163616
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ mod byte_str;
182182
mod error;
183183
mod extensions;
184184

185-
pub use crate::error::{Error, Result, CapacityOverflow};
185+
pub use crate::error::{Error, Result, MaxSizeReached};
186186
pub use crate::extensions::Extensions;
187187
#[doc(no_inline)]
188188
pub use crate::header::{HeaderMap, HeaderName, HeaderValue};

0 commit comments

Comments
 (0)