diff options
author | 2024-02-11 21:19:18 -0800 | |
---|---|---|
committer | 2024-02-11 21:19:18 -0800 | |
commit | ccc88a8b8a8f7ce9edf554d1a694f9a640ff75d5 (patch) | |
tree | 2a984e90ed9963d4ee1a0dcd701a43c434257068 | |
parent | 85301f17bedfe3a4e19e5e93e83afc463afdb02f (diff) | |
download | trakt-ccc88a8b8a8f7ce9edf554d1a694f9a640ff75d5.tar.gz trakt-ccc88a8b8a8f7ce9edf554d1a694f9a640ff75d5.tar.zst trakt-ccc88a8b8a8f7ce9edf554d1a694f9a640ff75d5.zip |
Fixes clippy lints
-rw-r--r-- | trakt/src/response.rs | 12 | ||||
-rw-r--r-- | trakt/src/smo.rs | 9 | ||||
-rw-r--r-- | trakt/src/utils.rs | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/trakt/src/response.rs b/trakt/src/response.rs index 7c714af..ddb10f3 100644 --- a/trakt/src/response.rs +++ b/trakt/src/response.rs @@ -1,6 +1,18 @@ use crate::error::ApiError; pub trait Response: Sized { + /// Converts an HTTP response into a result of `Self`, where `Self` refers to the implementing type. + /// + /// # Arguments + /// + /// * `response` - The HTTP response to convert. + /// + /// # Errors + /// + /// Will error if the HTTP response is not a succeeding status code as determined by the + /// type or if the response body cannot be deserialized into the implementing type. + /// + /// See [`FromHttpError`] for more details. fn try_from_http_response<T: AsRef<[u8]>>( response: http::Response<T>, ) -> Result<Self, FromHttpError>; diff --git a/trakt/src/smo.rs b/trakt/src/smo.rs index cb25964..69d1fdf 100644 --- a/trakt/src/smo.rs +++ b/trakt/src/smo.rs @@ -98,6 +98,15 @@ impl TwoLetter { Self(bytes) } + /// Create a `TwoLetter` from bytes without checking if the bytes are valid UTF-8 + /// + /// # Arguments + /// + /// * `bytes`: Bytes to convert to a `TwoLetter` + /// + /// # Safety + /// + /// The bytes must be valid UTF-8. #[must_use] pub const unsafe fn from_bytes_unchecked(bytes: [u8; 2]) -> Self { Self(bytes) diff --git a/trakt/src/utils.rs b/trakt/src/utils.rs index a355e8c..ff813f2 100644 --- a/trakt/src/utils.rs +++ b/trakt/src/utils.rs @@ -35,7 +35,7 @@ pub struct PaginationResponse<T> { } impl<T> PaginationResponse<T> { - pub fn from_headers(items: Vec<T>, map: &HeaderMap) -> Result<Self, DeserializeError> { + pub(crate) fn from_headers(items: Vec<T>, map: &HeaderMap) -> Result<Self, DeserializeError> { let current_page = parse_from_header(map, "X-Pagination-Page")?; let items_per_page = parse_from_header(map, "X-Pagination-Limit")?; let total_pages = parse_from_header(map, "X-Pagination-Page-Count")?; |