Skip to content

Commit

Permalink
Adds feature doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Apr 10, 2024
1 parent fddc099 commit f20ab9a
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/connection/_gss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ impl Connection {
/**
* Return true if GSSAPI encryption is in use
*/
#[cfg_attr(docsrs, doc(cfg(feature = "v12")))]
pub fn gss_enc_in_use(&self) -> bool {
unsafe { pq_sys::PQgssEncInUse(self.into()) != 0 }
}
Expand All @@ -13,6 +14,7 @@ impl Connection {
*
* This function returns a `void*` pointer.
*/
#[cfg_attr(docsrs, doc(cfg(feature = "v12")))]
pub fn gss_context(&self) -> *const std::ffi::c_void {
unsafe { pq_sys::PQgetgssctx(self.into()) }
}
Expand All @@ -24,6 +26,7 @@ impl Connection {
* [PQconnectionUsedGSSAPI](https://www.postgresql.org/docs/16/libpq-status.html#LIBPQ-PQCONNECTIONUSEDGSSAPI).
*/
#[cfg(feature = "v16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v16")))]
pub fn used_gssapi(&self) -> bool {
unsafe { pq_sys::PQconnectionUsedGSSAPI(self.into()) != 0 }
}
Expand Down
1 change: 1 addition & 0 deletions src/connection/_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl Connection {
* See [PQhostaddr](https://www.postgresql.org/docs/current/libpq-status.html#LIBPQ-PQHOSTADDR).
*/
#[cfg(feature = "v12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v12")))]
pub fn hostaddr(&self) -> crate::errors::Result<String> {
crate::ffi::to_string(unsafe { pq_sys::PQhostaddr(self.into()) })
}
Expand Down
1 change: 1 addition & 0 deletions src/connection/_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl Connection {
* Controls the tracing behavior of client/server communication.
*/
#[cfg(feature = "v14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub fn trace_set_flags(&self, flags: crate::trace::Flags) {
unsafe {
pq_sys::PQsetTraceFlags(self.into(), flags.bits() as i32);
Expand Down
4 changes: 4 additions & 0 deletions src/connection/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ pub enum Status {
Consume,
/** Negotiating GSSAPI. */
#[cfg(feature = "v11")]
#[cfg_attr(docsrs, doc(cfg(feature = "v11")))]
GssStartup,
/** Check if we have a proper target connection */
#[cfg(feature = "v11")]
#[cfg_attr(docsrs, doc(cfg(feature = "v11")))]
CheckTarget,
}

Expand All @@ -43,8 +45,10 @@ impl From<pq_sys::ConnStatusType> for Status {
pq_sys::ConnStatusType::CONNECTION_CHECK_WRITABLE => Self::CheckWritable,
pq_sys::ConnStatusType::CONNECTION_CONSUME => Self::Consume,
#[cfg(feature = "v11")]
#[cfg_attr(docsrs, doc(cfg(feature = "v11")))]
pq_sys::ConnStatusType::CONNECTION_GSS_STARTUP => Self::GssStartup,
#[cfg(feature = "v11")]
#[cfg_attr(docsrs, doc(cfg(feature = "v11")))]
pq_sys::ConnStatusType::CONNECTION_CHECK_TARGET => Self::CheckTarget,
#[allow(unreachable_patterns)]
_ => unreachable!(),
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(doc_cfg)]
#![warn(warnings)]
#![allow(clippy::missing_safety_doc)]

Expand Down
6 changes: 6 additions & 0 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub enum Status {
/** The libpq connection is *not* in pipeline mode. */
Off,
Expand Down Expand Up @@ -29,6 +30,7 @@ impl From<pq_sys::PGpipelineStatus> for Status {
* See
* [PQenterPipelineMode](https://www.postgresql.org/docs/current/libpq-pipeline-mode.html#LIBPQ-PQENTERPIPELINEMODE)
*/
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub fn enter(conn: &crate::Connection) -> crate::errors::Result {
log::debug!("Enter pipeline mode");

Expand All @@ -48,6 +50,7 @@ pub fn enter(conn: &crate::Connection) -> crate::errors::Result {
* See
* [PQexitPipelineMode](https://www.postgresql.org/docs/current/libpq-pipeline-mode.html#LIBPQ-PQEXITPIPELINEMODE)
*/
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub fn exit(conn: &crate::Connection) -> crate::errors::Result {
log::debug!("Exit pipeline mode");

Expand All @@ -66,6 +69,7 @@ pub fn exit(conn: &crate::Connection) -> crate::errors::Result {
* See
* [PQpipelineStatus](https://www.postgresql.org/docs/current/libpq-pipeline-mode.html#LIBPQ-PQPIPELINESTATUS)
*/
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub fn status(conn: &crate::Connection) -> Status {
let status = unsafe { pq_sys::PQpipelineStatus(conn.into()) };

Expand All @@ -79,6 +83,7 @@ pub fn status(conn: &crate::Connection) -> Status {
* See
* [PQpipelineSync](https://www.postgresql.org/docs/current/libpq-pipeline-mode.html#LIBPQ-PQPIPELINESYNC)
*/
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub fn sync(conn: &crate::Connection) -> crate::errors::Result {
let success = unsafe { pq_sys::PQpipelineSync(conn.into()) };

Expand All @@ -95,6 +100,7 @@ pub fn sync(conn: &crate::Connection) -> crate::errors::Result {
* See
* [PQsendFlushRequest](https://www.postgresql.org/docs/current/libpq-pipeline-mode.html#LIBPQ-PQSENDFLUSHREQUEST)
*/
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub fn flush_request(conn: &crate::Connection) -> crate::errors::Result {
let success = unsafe { pq_sys::PQsendFlushRequest(conn.into()) };

Expand Down
1 change: 1 addition & 0 deletions src/result/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ impl Result {
* See [PQresultMemorySize](https://www.postgresql.org/docs/current/libpq-exec.html#LIBPQ-PQRESULTMEMORYSIZE)
*/
#[cfg(feature = "v12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v12")))]
pub fn memory_size(&self) -> u64 {
unsafe { pq_sys::PQresultMemorySize(self.into()) as u64 }
}
Expand Down
6 changes: 6 additions & 0 deletions src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ pub enum Status {

/** Pipeline synchronization point. */
#[cfg(feature = "v14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
PipelineSync,

/** Command didn't run because of an abort earlier in a pipeline. */
#[cfg(feature = "v14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
PipelineAborted,
}

Expand All @@ -51,8 +53,10 @@ impl From<pq_sys::ExecStatusType> for Status {
pq_sys::ExecStatusType::PGRES_SINGLE_TUPLE => Self::SingleTuble,
pq_sys::ExecStatusType::PGRES_TUPLES_OK => Self::TupplesOk,
#[cfg(feature = "v14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pq_sys::ExecStatusType::PGRES_PIPELINE_SYNC => Self::PipelineSync,
#[cfg(feature = "v14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pq_sys::ExecStatusType::PGRES_PIPELINE_ABORTED => Self::PipelineAborted,
#[allow(unreachable_patterns)]
_ => unreachable!(),
Expand Down Expand Up @@ -82,8 +86,10 @@ impl From<&Status> for pq_sys::ExecStatusType {
Status::SingleTuble => pq_sys::ExecStatusType::PGRES_SINGLE_TUPLE,
Status::TupplesOk => pq_sys::ExecStatusType::PGRES_TUPLES_OK,
#[cfg(feature = "v14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
Status::PipelineSync => pq_sys::ExecStatusType::PGRES_PIPELINE_SYNC,
#[cfg(feature = "v14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
Status::PipelineAborted => pq_sys::ExecStatusType::PGRES_PIPELINE_ABORTED,
#[allow(unreachable_patterns)]
_ => unreachable!(),
Expand Down
1 change: 1 addition & 0 deletions src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ bitflags::bitflags! {
* Flags controlling trace output.
*/
#[repr(transparent)]
#[cfg_attr(docsrs, doc(cfg(feature = "v14")))]
pub struct Flags : u32 {
/** Omit timestamps from each line. */
const SUPPRESS_TIMESTAMPS = pq_sys::PQTRACE_SUPPRESS_TIMESTAMPS;
Expand Down
3 changes: 3 additions & 0 deletions src/verbosity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum Verbosity {
Verbose,
/** only error severity and SQLSTATE code */
#[cfg(feature = "v11")]
#[cfg_attr(docsrs, doc(cfg(feature = "v11")))]
Sqlstate,
}

Expand All @@ -22,6 +23,7 @@ impl From<pq_sys::PGVerbosity> for Verbosity {
pq_sys::PGVerbosity::PQERRORS_DEFAULT => Self::Default,
pq_sys::PGVerbosity::PQERRORS_VERBOSE => Self::Verbose,
#[cfg(feature = "v11")]
#[cfg_attr(docsrs, doc(cfg(feature = "v11")))]
pq_sys::PGVerbosity::PQERRORS_SQLSTATE => Self::Sqlstate,
#[allow(unreachable_patterns)]
_ => unreachable!(),
Expand All @@ -37,6 +39,7 @@ impl From<Verbosity> for pq_sys::PGVerbosity {
Verbosity::Default => pq_sys::PGVerbosity::PQERRORS_DEFAULT,
Verbosity::Verbose => pq_sys::PGVerbosity::PQERRORS_VERBOSE,
#[cfg(feature = "v11")]
#[cfg_attr(docsrs, doc(cfg(feature = "v11")))]
Verbosity::Sqlstate => pq_sys::PGVerbosity::PQERRORS_SQLSTATE,
#[allow(unreachable_patterns)]
_ => unreachable!(),
Expand Down

0 comments on commit f20ab9a

Please sign in to comment.