Skip to content

Commit d82e2fb

Browse files
committed
Use Query::len(&self) for len checks
1 parent 458ade8 commit d82e2fb

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

src/aio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ macro_rules! impl_async_methods {
4646
/// ## Panics
4747
/// This method will panic if the [`Query`] supplied is empty (i.e has no arguments)
4848
pub async fn run_simple_query(&mut self, query: &Query) -> IoResult<Response> {
49-
assert!(query.__len() != 0, "A `Query` cannot be of zero length!");
49+
assert!(query.len() != 0, "A `Query` cannot be of zero length!");
5050
query.write_query_to(&mut self.stream).await?;
5151
self.stream.flush().await?;
5252
loop {

src/lib.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,6 @@ impl Query {
385385
pub fn is_empty(&self) -> bool {
386386
self.size_count == 0
387387
}
388-
/// Number of items in the datagroup
389-
pub(crate) fn __len(&self) -> usize {
390-
self.size_count
391-
}
392388
fn get_holding_buffer(&self) -> &[u8] {
393389
&self.data
394390
}
@@ -401,7 +397,7 @@ impl Query {
401397
// Write the metaframe
402398
stream.write_all(b"*1\n").await?;
403399
// Add the dataframe
404-
let number_of_items_in_datagroup = self.__len().to_string().into_bytes();
400+
let number_of_items_in_datagroup = self.len().to_string().into_bytes();
405401
stream.write_all(&[b'~']).await?;
406402
stream.write_all(&number_of_items_in_datagroup).await?;
407403
stream.write_all(&[b'\n']).await?;
@@ -419,7 +415,7 @@ impl Query {
419415
// Write the metaframe
420416
stream.write_all(b"*1\n")?;
421417
// Add the dataframe
422-
let number_of_items_in_datagroup = self.__len().to_string().into_bytes();
418+
let number_of_items_in_datagroup = self.len().to_string().into_bytes();
423419
stream.write_all(&[b'~'])?;
424420
stream.write_all(&number_of_items_in_datagroup)?;
425421
stream.write_all(&[b'\n'])?;
@@ -438,7 +434,7 @@ impl Query {
438434
pub fn into_raw_query(self) -> Vec<u8> {
439435
let mut v = Vec::with_capacity(self.data.len());
440436
v.extend(b"*1\n~");
441-
v.extend(self.__len().to_string().into_bytes());
437+
v.extend(self.len().to_string().into_bytes());
442438
v.extend(b"\n");
443439
v.extend(self.get_holding_buffer());
444440
v
@@ -507,6 +503,8 @@ cfg_dbg!(
507503
pub mod error {
508504
//! Errors
509505
cfg_ssl_any!(
506+
use crate::RespCode;
507+
use std::io::ErrorKind;
510508
use std::fmt;
511509
/// Errors that may occur while initiating an [async TLS connection](crate::aio::TlsConnection)
512510
/// or a [sync TLS connection](crate::sync::TlsConnection)
@@ -549,12 +547,19 @@ pub mod error {
549547
#[non_exhaustive]
550548
/// An error originating from the Skyhash protocol
551549
pub enum SkyhashError {
550+
/// The server sent data but we failed to parse it
551+
ParseError,
552+
/// The server sent an unexpected data type for this action
553+
UnexpectedDataType,
554+
/// The server sent an unknown data type that we cannot parse
555+
UnknownDataType,
552556
/// The server sent an invalid response
553557
InvalidResponse,
554-
/// The server sent a response but it could not be parsed
555-
ParseError,
556-
/// The server sent a data type not supported by this client version
557-
UnsupportedDataType,
558+
/// An I/O error occurred while running this action
559+
IoError(ErrorKind),
560+
/// The server returned a response code **other than the one that should have been returned
561+
/// for this action** (if any)
562+
Code(RespCode),
558563
}
559564

560565
#[derive(Debug)]

src/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ macro_rules! impl_sync_methods {
4242
/// This method will panic if the [`Query`] supplied is empty (i.e has no arguments)
4343
/// This function is a subroutine of `run_query` used to parse the response packet
4444
pub fn run_simple_query(&mut self, query: &Query) -> IoResult<Response> {
45-
assert!(query.__len() != 0, "A `Query` cannot be of zero length!");
45+
assert!(query.len() != 0, "A `Query` cannot be of zero length!");
4646
query.write_query_to_sync(&mut self.stream)?;
4747
self.stream.flush()?;
4848
loop {

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ use core::ops::DerefMut;
110110
/// ```
111111
///
112112
pub trait IntoSkyhashBytes: Send + Sync {
113-
/// Turn `Self` into a [`String`]
113+
/// Turn `Self` into a [`Vec<u8>`]
114114
fn to_bytes(&self) -> Vec<u8>;
115115
}
116116

0 commit comments

Comments
 (0)