Skip to content

Commit

Permalink
docs: deprecate and hide from_maybe_shared constructors from docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tesaguri committed Oct 26, 2024
1 parent 88163ad commit 88b7b54
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
19 changes: 4 additions & 15 deletions src/header/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@ impl HeaderValue {
HeaderValue::try_from_generic(src, Bytes::copy_from_slice)
}

/// Attempt to convert a `Bytes` buffer to a `HeaderValue`.
///
/// This will try to prevent a copy if the type passed is the type used
/// internally, and will copy the data if it is not.
#[deprecated = "Use TryFrom::<Bytes>::try_from instead"]
#[doc(hidden)]
pub fn from_maybe_shared<T>(src: T) -> Result<HeaderValue, InvalidHeaderValue>
where
T: AsRef<[u8]> + 'static,
Expand Down Expand Up @@ -222,17 +220,8 @@ impl HeaderValue {
}
}

/// Convert a `Bytes` directly into a `HeaderValue` without validating.
///
/// This function does NOT validate that illegal bytes are not contained
/// within the buffer.
///
/// ## Panics
/// In a debug build this will panic if `src` is not valid UTF-8.
///
/// ## Safety
/// `src` must contain valid UTF-8. In a release build it is undefined
/// behaviour to call this with `src` that is not valid UTF-8.
#[deprecated = "Use from_shared_unchecked instead"]
#[doc(hidden)]
pub unsafe fn from_maybe_shared_unchecked<T>(src: T) -> HeaderValue
where
T: AsRef<[u8]> + 'static,
Expand Down
6 changes: 2 additions & 4 deletions src/uri/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ impl Authority {
.expect("static str is not valid authority")
}

/// Attempt to convert a `Bytes` buffer to a `Authority`.
///
/// This will try to prevent a copy if the type passed is the type used
/// internally, and will copy the data if it is not.
#[deprecated = "Use TryFrom::<Bytes>::try_from instead"]
#[doc(hidden)]
pub fn from_maybe_shared<T>(src: T) -> Result<Self, InvalidUri>
where
T: AsRef<[u8]> + 'static,
Expand Down
6 changes: 2 additions & 4 deletions src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,8 @@ impl Uri {
})
}

/// Attempt to convert a `Bytes` buffer to a `Uri`.
///
/// This will try to prevent a copy if the type passed is the type used
/// internally, and will copy the data if it is not.
#[deprecated = "Use TryFrom::<Bytes>::try_from instead"]
#[doc(hidden)]
pub fn from_maybe_shared<T>(src: T) -> Result<Self, InvalidUri>
where
T: AsRef<[u8]> + 'static,
Expand Down
6 changes: 2 additions & 4 deletions src/uri/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ impl PathAndQuery {
PathAndQuery::try_from(src).unwrap()
}

/// Attempt to convert a `Bytes` buffer to a `PathAndQuery`.
///
/// This will try to prevent a copy if the type passed is the type used
/// internally, and will copy the data if it is not.
#[deprecated = "Use TryFrom::<Bytes>::try_from instead"]
#[doc(hidden)]
pub fn from_maybe_shared<T>(src: T) -> Result<Self, InvalidUri>
where
T: AsRef<[u8]> + 'static,
Expand Down

0 comments on commit 88b7b54

Please sign in to comment.