Skip to content

Commit 87e99e9

Browse files
committed
Rename SkyRawResult and SkyResult
`SkyRawResult` is now `SkyResult` with a generic parameter while `SkyResult` is now `SkyQueryResult`. This change was done following naming guidelines and to reduce ambiguity.
1 parent b471f50 commit 87e99e9

File tree

9 files changed

+45
-38
lines changed

9 files changed

+45
-38
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All changes in this project will be noted in this file.
44

5+
## Unreleased
6+
7+
### Breaking changes
8+
9+
- `SkyRawResult` is now `SkyResult`
10+
- `SkyResult` is now `SkyQueryResult`
11+
512
## Version 0.6.2
613

714
- Added support for pipelined queries

examples/custom-types/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use skytable::sync::Connection;
55
use skytable::types::FromSkyhashBytes;
66
use skytable::types::IntoSkyhashBytes;
77
use skytable::Element;
8-
use skytable::SkyRawResult;
8+
use skytable::SkyResult;
99

1010
/// Our custom user type
1111
#[derive(Serialize, Deserialize, PartialEq, Debug)]
@@ -34,7 +34,7 @@ impl IntoSkyhashBytes for &User {
3434

3535
// Implement this for our type so that we can directly use it with actions/queries
3636
impl FromSkyhashBytes for User {
37-
fn from_element(e: Element) -> SkyRawResult<Self> {
37+
fn from_element(e: Element) -> SkyResult<Self> {
3838
// we want our JSON as a string
3939
let my_value_as_string: String = e.try_element_into()?;
4040
// now let us convert it into our struct

src/actions.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use crate::IntoSkyhashAction;
4848
use crate::IntoSkyhashBytes;
4949
use crate::Query;
5050
use crate::RespCode;
51-
use crate::SkyRawResult;
51+
use crate::SkyQueryResult;
5252
use crate::SkyResult;
5353

5454
cfg_async!(
@@ -62,7 +62,7 @@ cfg_async!(
6262
/// A raw async connection to the database server
6363
pub trait AsyncSocket: Send + Sync {
6464
/// Run the query
65-
fn run(&mut self, q: Query) -> AsyncResult<SkyResult>;
65+
fn run(&mut self, q: Query) -> AsyncResult<SkyQueryResult>;
6666
}
6767
impl<T> AsyncActions for T where T: AsyncSocket {}
6868
);
@@ -72,7 +72,7 @@ cfg_sync!(
7272
/// A raw synchronous connection to the database server
7373
pub trait SyncSocket {
7474
/// Run the query
75-
fn run(&mut self, q: Query) -> SkyResult;
75+
fn run(&mut self, q: Query) -> SkyQueryResult;
7676
}
7777
impl<T> Actions for T where T: SyncSocket {}
7878
);
@@ -106,7 +106,7 @@ macro_rules! implement_actions {
106106
$(
107107
$(#[$attr])*
108108
#[inline]
109-
fn $name<'s, $($($tyargs$(: $ty $(+$tye)*,)* )*)?>(&'s mut self $(, $argname: $argty)*) -> SkyRawResult<$ret> {
109+
fn $name<'s, $($($tyargs$(: $ty $(+$tye)*,)* )*)?>(&'s mut self $(, $argname: $argty)*) -> SkyResult<$ret> {
110110
gen_match!(self.run($($block)?), $($($mtch)+, $expect),*)
111111
}
112112
)*
@@ -118,7 +118,7 @@ macro_rules! implement_actions {
118118
$(
119119
$(#[$attr])*
120120
#[inline]
121-
fn $name<'s, $($($tyargs$(: $ty $(+$tye)*,)* )*)?>(&'s mut self $(, $argname: $argty)*) -> AsyncResult<SkyRawResult<$ret>> {
121+
fn $name<'s, $($($tyargs$(: $ty $(+$tye)*,)* )*)?>(&'s mut self $(, $argname: $argty)*) -> AsyncResult<SkyResult<$ret>> {
122122
Box::pin(async move {gen_match!(self.run($($block)?).await, $($($mtch)+, $expect),*)})
123123
}
124124
)*

src/aio.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::Element;
3131
use crate::IoResult;
3232
use crate::Pipeline;
3333
use crate::Query;
34-
use crate::SkyRawResult;
34+
use crate::SkyQueryResult;
3535
use crate::SkyResult;
3636
use crate::WriteQueryAsync;
3737
use bytes::{Buf, BytesMut};
@@ -52,15 +52,15 @@ macro_rules! impl_async_methods {
5252
///
5353
/// ## Panics
5454
/// This method will panic if the [`Query`] supplied is empty (i.e has no arguments)
55-
pub async fn run_simple_query(&mut self, query: &Query) -> SkyResult {
55+
pub async fn run_simple_query(&mut self, query: &Query) -> SkyQueryResult {
5656
match self._run_query(query).await? {
5757
RawResponse::SimpleQuery(sq) => Ok(sq),
5858
RawResponse::PipelinedQuery(_) => Err(SkyhashError::InvalidResponse.into()),
5959
}
6060
}
6161
/// Runs a pipelined query. See the [`Pipeline`](Pipeline) documentation for a guide on
6262
/// usage
63-
pub async fn run_pipeline(&mut self, pipeline: Pipeline) -> SkyRawResult<Vec<Element>> {
63+
pub async fn run_pipeline(&mut self, pipeline: Pipeline) -> SkyResult<Vec<Element>> {
6464
match self._run_query(&pipeline).await? {
6565
RawResponse::PipelinedQuery(pq) => Ok(pq),
6666
RawResponse::SimpleQuery(_) => Err(SkyhashError::InvalidResponse.into()),
@@ -69,7 +69,7 @@ macro_rules! impl_async_methods {
6969
async fn _run_query<Q: WriteQueryAsync<$inner>>(
7070
&mut self,
7171
query: &Q,
72-
) -> SkyRawResult<RawResponse> {
72+
) -> SkyResult<RawResponse> {
7373
query.write_async(&mut self.stream).await?;
7474
self.stream.flush().await?;
7575
loop {
@@ -110,7 +110,7 @@ macro_rules! impl_async_methods {
110110
}
111111
}
112112
impl crate::actions::AsyncSocket for $ty {
113-
fn run(&mut self, q: Query) -> crate::actions::AsyncResult<SkyResult> {
113+
fn run(&mut self, q: Query) -> crate::actions::AsyncResult<SkyQueryResult> {
114114
Box::pin(async move { self.run_simple_query(&q).await })
115115
}
116116
}

src/ddl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::Element;
4040
use crate::IntoSkyhashBytes;
4141
use crate::Query;
4242
use crate::RespCode;
43-
use crate::SkyRawResult;
43+
use crate::SkyResult;
4444

4545
cfg_async! {
4646
use crate::actions::AsyncResult;
@@ -182,7 +182,7 @@ macro_rules! implement_ddl {
182182
$(
183183
$(#[$attr])*
184184
#[inline]
185-
fn $name<'s, $($($tyargs: $ty $(+$tye)*, )*)?>(&'s mut self $(, $argname: $argty)*) -> SkyRawResult<$ret> {
185+
fn $name<'s, $($($tyargs: $ty $(+$tye)*, )*)?>(&'s mut self $(, $argname: $argty)*) -> SkyResult<$ret> {
186186
gen_match!(self.run($($block)?), $($($mtch)+, $expect),*)
187187
}
188188
)*
@@ -195,7 +195,7 @@ macro_rules! implement_ddl {
195195
$(
196196
$(#[$attr])*
197197
#[inline]
198-
fn $name<'s, $($($tyargs: $ty $(+$tye)*, )*)?>(&'s mut self $(, $argname: $argty)*) -> AsyncResult<SkyRawResult<$ret>> {
198+
fn $name<'s, $($($tyargs: $ty $(+$tye)*, )*)?>(&'s mut self $(, $argname: $argty)*) -> AsyncResult<SkyResult<$ret>> {
199199
Box::pin(async move {gen_match!(self.run($($block)?).await, $($($mtch)+, $expect),*)})
200200
}
201201
)*

src/deserializer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::types::Array;
3131
use crate::types::FlatElement;
3232
use crate::types::FromSkyhashBytes;
3333
use crate::RespCode;
34-
use crate::SkyRawResult;
34+
use crate::SkyResult;
3535
use std::hint::unreachable_unchecked;
3636

3737
#[derive(Debug)]
@@ -83,7 +83,7 @@ pub enum Element {
8383

8484
impl Element {
8585
/// Try to convert an element to a type that implements [`FromSkyhashBytes`]
86-
pub fn try_element_into<T: FromSkyhashBytes>(self) -> SkyRawResult<T> {
86+
pub fn try_element_into<T: FromSkyhashBytes>(self) -> SkyResult<T> {
8787
T::from_element(self)
8888
}
8989
}

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ cfg_sync!(
212212
);
213213

214214
/// A generic result type
215-
pub type SkyRawResult<T> = Result<T, self::error::Error>;
216-
/// A specialized error type for queries
217-
pub type SkyResult = SkyRawResult<Element>;
215+
pub type SkyResult<T> = Result<T, self::error::Error>;
216+
/// A result type for queries
217+
pub type SkyQueryResult = SkyResult<Element>;
218218

219219
#[derive(Debug, Clone)]
220220
/// A connection builder for easily building connections
@@ -283,7 +283,7 @@ impl ConnectionBuilder {
283283
}
284284
cfg_sync! {
285285
/// Get a [sync connection](sync::Connection) to the database
286-
pub fn get_connection(&self) -> SkyRawResult<sync::Connection> {
286+
pub fn get_connection(&self) -> SkyResult<sync::Connection> {
287287
use crate::ddl::Ddl;
288288
let mut con =
289289
sync::Connection::new(self.host.as_ref().unwrap_or(&DEFAULT_HOSTADDR.to_owned()), self.port.unwrap_or(2003))?;
@@ -295,7 +295,7 @@ impl ConnectionBuilder {
295295
pub fn get_tls_connection(
296296
&self,
297297
sslcert: String,
298-
) -> SkyRawResult<sync::TlsConnection> {
298+
) -> SkyResult<sync::TlsConnection> {
299299
use crate::ddl::Ddl;
300300
let mut con = sync::TlsConnection::new(
301301
self.host.as_ref().unwrap_or(&DEFAULT_HOSTADDR.to_owned()),
@@ -309,7 +309,7 @@ impl ConnectionBuilder {
309309
}
310310
cfg_async! {
311311
/// Get an [async connection](aio::Connection) to the database
312-
pub async fn get_async_connection(&self) -> SkyRawResult<aio::Connection> {
312+
pub async fn get_async_connection(&self) -> SkyResult<aio::Connection> {
313313
use crate::ddl::AsyncDdl;
314314
let mut con = aio::Connection::new(self.host.as_ref().unwrap_or(&DEFAULT_HOSTADDR.to_owned()), self.port.unwrap_or(2003))
315315
.await?;
@@ -321,7 +321,7 @@ impl ConnectionBuilder {
321321
pub async fn get_async_tls_connection(
322322
&self,
323323
sslcert: String,
324-
) -> SkyRawResult<aio::TlsConnection> {
324+
) -> SkyResult<aio::TlsConnection> {
325325
use crate::ddl::AsyncDdl;
326326
let mut con = aio::TlsConnection::new(
327327
self.host.as_ref().unwrap_or(&DEFAULT_HOSTADDR.to_owned()),

src/sync.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::Element;
3030
use crate::IoResult;
3131
use crate::Pipeline;
3232
use crate::Query;
33-
use crate::SkyRawResult;
33+
use crate::SkyQueryResult;
3434
use crate::SkyResult;
3535
use crate::WriteQuerySync;
3636
use std::io::{Error as IoError, ErrorKind, Read, Write};
@@ -48,7 +48,7 @@ macro_rules! impl_sync_methods {
4848
/// This method will panic:
4949
/// - if the [`Query`] supplied is empty (i.e has no arguments)
5050
/// This function is a subroutine of `run_query` used to parse the response packet
51-
pub fn run_simple_query(&mut self, query: &Query) -> SkyResult {
51+
pub fn run_simple_query(&mut self, query: &Query) -> SkyQueryResult {
5252
assert!(query.len() != 0, "A `Query` cannot be of zero length!");
5353
match self._run_query(query)? {
5454
RawResponse::SimpleQuery(sq) => Ok(sq),
@@ -57,14 +57,14 @@ macro_rules! impl_sync_methods {
5757
}
5858
/// Runs a pipelined query. See the [`Pipeline`](Pipeline) documentation for a guide on
5959
/// usage
60-
pub fn run_pipeline(&mut self, pipeline: Pipeline) -> SkyRawResult<Vec<Element>> {
60+
pub fn run_pipeline(&mut self, pipeline: Pipeline) -> SkyResult<Vec<Element>> {
6161
assert!(pipeline.len() != 0, "A `Pipeline` cannot be empty!");
6262
match self._run_query(&pipeline)? {
6363
RawResponse::PipelinedQuery(pq) => Ok(pq),
6464
RawResponse::SimpleQuery(_) => Err(SkyhashError::InvalidResponse.into()),
6565
}
6666
}
67-
fn _run_query<T: WriteQuerySync>(&mut self, query: &T) -> SkyRawResult<RawResponse> {
67+
fn _run_query<T: WriteQuerySync>(&mut self, query: &T) -> SkyResult<RawResponse> {
6868
query.write_sync(&mut self.stream)?;
6969
self.stream.flush()?;
7070
loop {
@@ -109,7 +109,7 @@ macro_rules! impl_sync_methods {
109109
}
110110
}
111111
impl crate::actions::SyncSocket for $ty {
112-
fn run(&mut self, q: Query) -> SkyResult {
112+
fn run(&mut self, q: Query) -> SkyQueryResult {
113113
self.run_simple_query(&q)
114114
}
115115
}

src/types.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ use crate::error::Error;
8989
use crate::Element;
9090
use crate::Query;
9191
use crate::RespCode;
92-
use crate::SkyRawResult;
92+
use crate::SkyResult;
9393
use core::convert::TryInto;
9494
use core::ops::Deref;
9595
use core::ops::DerefMut;
@@ -410,7 +410,7 @@ impl<'a> IntoSkyhashBytes for &'a RawString {
410410
/// ```no_run
411411
/// use skytable::types::FromSkyhashBytes;
412412
/// use skytable::error::Error;
413-
/// use skytable::{SkyRawResult, Element};
413+
/// use skytable::{SkyResult, Element};
414414
///
415415
/// pub struct MyCSV {
416416
/// name: String,
@@ -420,7 +420,7 @@ impl<'a> IntoSkyhashBytes for &'a RawString {
420420
///
421421
/// // Implement it
422422
/// impl FromSkyhashBytes for MyCSV {
423-
/// fn from_element(element: Element) -> SkyRawResult<Self> {
423+
/// fn from_element(element: Element) -> SkyResult<Self> {
424424
/// if let Element::String(st) = element {
425425
/// let splits: Vec<&str> = st.split(",").collect();
426426
/// Ok(
@@ -449,13 +449,13 @@ impl<'a> IntoSkyhashBytes for &'a RawString {
449449
///
450450
pub trait FromSkyhashBytes: Sized {
451451
/// Attempt to convert an element to the target type, returning errors if they occur
452-
fn from_element(element: Element) -> SkyRawResult<Self>;
452+
fn from_element(element: Element) -> SkyResult<Self>;
453453
}
454454

455455
macro_rules! impl_from_skyhash {
456456
($($ty:ty),* $(,)?) => {
457457
$(impl FromSkyhashBytes for $ty {
458-
fn from_element(element: Element) -> SkyRawResult<$ty> {
458+
fn from_element(element: Element) -> SkyResult<$ty> {
459459
let ret = match element {
460460
Element::Binstr(bstr) => String::from_utf8_lossy(&bstr).parse::<$ty>()?,
461461
Element::String(st) => st.parse::<$ty>()?,
@@ -471,7 +471,7 @@ macro_rules! impl_from_skyhash {
471471
impl_from_skyhash!(u8, i8, u16, i16, u32, i32, u64, i64, u128, i128, usize, isize);
472472

473473
impl FromSkyhashBytes for String {
474-
fn from_element(element: Element) -> SkyRawResult<String> {
474+
fn from_element(element: Element) -> SkyResult<String> {
475475
let e = match element {
476476
Element::Binstr(bstr) => std::string::String::from_utf8(bstr)?,
477477
Element::String(st) => st,
@@ -483,7 +483,7 @@ impl FromSkyhashBytes for String {
483483
}
484484

485485
impl FromSkyhashBytes for Vec<String> {
486-
fn from_element(element: Element) -> SkyRawResult<Self> {
486+
fn from_element(element: Element) -> SkyResult<Self> {
487487
let e = match element {
488488
Element::Array(Array::Bin(binarr)) => {
489489
let mut new_arr = Vec::with_capacity(binarr.len());
@@ -514,7 +514,7 @@ impl FromSkyhashBytes for Vec<String> {
514514
}
515515

516516
impl FromSkyhashBytes for Vec<Vec<u8>> {
517-
fn from_element(e: Element) -> SkyRawResult<Self> {
517+
fn from_element(e: Element) -> SkyResult<Self> {
518518
let e = match e {
519519
Element::Array(Array::Bin(brr)) => {
520520
let mut newarr = Vec::with_capacity(brr.len());
@@ -545,7 +545,7 @@ impl FromSkyhashBytes for Vec<Vec<u8>> {
545545
}
546546

547547
impl FromSkyhashBytes for Element {
548-
fn from_element(e: Element) -> SkyRawResult<Element> {
548+
fn from_element(e: Element) -> SkyResult<Element> {
549549
Ok(e)
550550
}
551551
}

0 commit comments

Comments
 (0)