Skip to content

Commit

Permalink
feat: add HeaderMap::try_ methods to handle capacity overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
glebpom authored and seanmonstar committed Mar 4, 2024
1 parent 63102bc commit caa8b4f
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 109 deletions.
11 changes: 11 additions & 0 deletions src/error.rs
Expand Up @@ -3,6 +3,7 @@ use std::fmt;
use std::result;

use crate::header;
use crate::header::MaxSizeReached;
use crate::method;
use crate::status;
use crate::uri;
Expand All @@ -27,6 +28,7 @@ enum ErrorKind {
UriParts(uri::InvalidUriParts),
HeaderName(header::InvalidHeaderName),
HeaderValue(header::InvalidHeaderValue),
MaxSizeReached(MaxSizeReached),
}

impl fmt::Debug for Error {
Expand Down Expand Up @@ -61,6 +63,7 @@ impl Error {
UriParts(ref e) => e,
HeaderName(ref e) => e,
HeaderValue(ref e) => e,
MaxSizeReached(ref e) => e,
}
}
}
Expand All @@ -73,6 +76,14 @@ impl error::Error for Error {
}
}

impl From<MaxSizeReached> for Error {
fn from(err: MaxSizeReached) -> Error {
Error {
inner: ErrorKind::MaxSizeReached(err),
}
}
}

impl From<status::InvalidStatusCode> for Error {
fn from(err: status::InvalidStatusCode) -> Error {
Error {
Expand Down

0 comments on commit caa8b4f

Please sign in to comment.