[][src]Struct pgx::PgTryResult

#[must_use =
  "this `PgTryResult` may be be holding a Postgres ERROR.  It must be consumed or rethrown"]pub struct PgTryResult<T>(_);

A std::result::Result-type value returned from pg_try() that allows for performing cleanup work after a closure raised an error and before it is possibly rethrown

Implementations

impl<T> PgTryResult<T>[src]

pub fn unwrap(self) -> T[src]

Retrieve the returned value or panic if the try block raised an error

pub unsafe fn unwrap_or(self, value: T) -> T[src]

Safety

This function is unsafe because you might be ignoring a caught Postgres ERROR (or Rust panic) and you better know what you're doing when you do that.

Doing so can potentially leave Postgres in an undefined state and ultimately cause it to crash.

pub unsafe fn unwrap_or_else<F>(self, cleanup: F) -> T where
    F: FnOnce() -> T, 
[src]

Perform some operation cleanup operation after the try block if an error was thrown.

Safety

This function does not rethrow a caught ERROR. You better know what you're doing when you call this function.

Ignoring a caught error can leave Postgres in an undefined state and ultimately cause it to crash.

pub fn unwrap_or_rethrow<F>(self, cleanup: F) -> T where
    F: FnOnce(), 
[src]

Perform some operation cleanup operation after the try block if an error was thrown.

In the event an error was caught, it is rethrown.

pub fn finally_or_rethrow<F>(self, finally_block: F) -> T where
    F: FnOnce(), 
[src]

Perform some operation after the try block completes, regardless of if an error was thrown.

In the event an error was caught, it is rethrown. Otherwise, the return value from the try block is returned

Auto Trait Implementations

impl<T> !RefUnwindSafe for PgTryResult<T>[src]

impl<T> Send for PgTryResult<T> where
    T: Send
[src]

impl<T> !Sync for PgTryResult<T>[src]

impl<T> Unpin for PgTryResult<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for PgTryResult<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.