Skip to content

Commit

Permalink
more doc comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow committed Apr 22, 2024
1 parent 00f7d1e commit 7ed303e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
8 changes: 4 additions & 4 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ http1 = ["httparse", "xitca-http/http1"]
http2 = ["h2", "itoa", "xitca-http/http2"]
# http/3 client(tls always enabled with rustls)
http3 = ["h3", "h3-quinn", "quinn/tls-rustls", "itoa", "async-stream", "rustls_0dot21", "webpki_roots_0dot25"]
# openssl as http/1 and http/2 tls handler.
# openssl as http/1 and http/2 tls handler
openssl = ["xitca-tls/openssl"]
# rustls as http/1 and http/2 tls handler
rustls = ["xitca-tls/rustls", "webpki-roots"]
Expand All @@ -22,11 +22,11 @@ rustls-ring-crypto = ["xitca-tls/rustls-ring-crypto", "webpki-roots"]
compress = ["http-encoding"]
# json response body parsing support
json = ["serde", "serde_json"]
# websocket support
# websocket support. must be used together with http/1 and/or http/2 feature(s)
websocket = ["http-ws"]
# feature for testing niche client side usage and correctness of server implemenation:
# feature for trusted local network:
# - http/2 clear text over plain tcp connection
# - http/3 connection to server with self signed certificates.
# - http/3 connection to server with self signed certificates
dangerous = ["rustls_0dot21/dangerous_configuration"]

[dependencies]
Expand Down
19 changes: 14 additions & 5 deletions client/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! strongly typed library error.
use std::{convert::Infallible, error, fmt, io, str};
use core::{convert::Infallible, fmt, str};

use std::{error, io};

use super::http::{uri, StatusCode};

Expand Down Expand Up @@ -29,7 +31,14 @@ impl fmt::Display for Error {
}
}

impl error::Error for Error {}
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Self::Std(e) => e.source(),
_ => None,
}
}
}

impl From<io::Error> for Error {
fn from(e: io::Error) -> Self {
Expand Down Expand Up @@ -280,7 +289,7 @@ pub enum FeatureError {
Http1NotEnabled,
Http2NotEnabled,
Http3NotEnabled,
TlsNotEnabled,
DangerNotEnabled,
}

impl fmt::Display for FeatureError {
Expand All @@ -289,9 +298,9 @@ impl fmt::Display for FeatureError {
Self::Http1NotEnabled => f.write_str("http1")?,
Self::Http2NotEnabled => f.write_str("http2")?,
Self::Http3NotEnabled => f.write_str("http3")?,
Self::TlsNotEnabled => f.write_str("openssl or rustls")?,
Self::DangerNotEnabled => f.write_str("dangerous")?,
};
f.write_str(" crate feature is not enabled")
f.write_str(" crate feature is not enabled.")
}
}

Expand Down
5 changes: 5 additions & 0 deletions client/src/pool/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#![allow(dead_code)]

// pool for http/1 connections. connection is uniquely owned and ownership is exchanged between
// pool and caller.
pub(crate) mod exclusive;

// pool for http/2 and http/3 connections. connection is shared owned and ownership is reference
// counted between pool and caller.
pub(crate) mod shared;
5 changes: 1 addition & 4 deletions client/src/tls/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ pub(crate) fn nop() -> Connector {
async fn call(&self, (_, _io): (&'n str, TlsStream)) -> Result<Self::Response, Self::Error> {
#[cfg(not(feature = "dangerous"))]
{
Err(crate::error::FeatureError::TlsNotEnabled.into())
Err(crate::error::FeatureError::DangerNotEnabled.into())
}

#[cfg(feature = "dangerous")]
{
// Enable HTTP/2 over plain TCP connection with dangerous feature.
//
// *. This is meant for test and local network usage. DO NOT use in internet environment.
Ok((_io, Version::HTTP_2))
}
}
Expand Down
2 changes: 1 addition & 1 deletion postgres/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl AsyncLendingIterator for PipelineItem<'_, '_> {
type Err = Error;

async fn try_next(&mut self) -> Result<Option<Self::Ok<'_>>, Self::Err> {
while !self.finished {
if !self.finished {
match self.stream.res.recv().await? {
backend::Message::DataRow(body) => {
return Row::try_new(self.columns, body, &mut self.stream.ranges).map(Some);
Expand Down
7 changes: 3 additions & 4 deletions postgres/src/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! proxy serves as a sample implementation of server side traffic forwarder
//! between a xitca-postgres Client with `quic` feature enabled and the postgres
//! database server.
//! transparent proxy serves as a sample implementation of server side traffic forwarder
//! between a xitca-postgres Client with `quic` feature enabled and the postgres database
use std::{
collections::HashSet,
Expand All @@ -24,7 +23,7 @@ use super::driver::quic::QUIC_ALPN;

pub type Error = Box<dyn error::Error + Send + Sync>;

/// proxy for translating multiplexed quic traffic to plain tcp traffic for postgres protocol.
/// proxy for forwarding multiplexed quic traffic to plain tcp traffic
pub struct Proxy {
cfg: Result<ServerConfig, Error>,
upstream_addr: SocketAddr,
Expand Down

0 comments on commit 7ed303e

Please sign in to comment.