pub async fn try_acquire<C: AsMut<PgConnection>>(
        &self,
        mut conn: C,
    ) -> Result<Either<PgAdvisoryLockGuard<'_, C>, C>> {
        let locked: bool = match &self.key {
            PgAdvisoryLockKey::BigInt(key) => {
                crate::query_scalar::query_scalar("SELECT pg_try_advisory_lock($1)")
                    .bind(key)
                    .fetch_one(conn.as_mut())
                    .await?
            }
            PgAdvisoryLockKey::IntPair(key1, key2) => {
                crate::query_scalar::query_scalar("SELECT pg_try_advisory_lock($1, $2)")
                    .bind(key1)
                    .bind(key2)
                    .fetch_one(conn.as_mut())
                    .await?
            }
        };

        if locked {
            Ok(Either::Left(PgAdvisoryLockGuard::new(self, conn)))
        } else {
            Ok(Either::Right(conn))
        }
    }
/// Acquires an exclusive lock using `pg_try_advisory_lock()`, returning immediately
/// if the lock could not be acquired.
///
/// For a version that waits until the lock is acquired, see [`Self::acquire()`].
///
/// A connection-like type is required to execute the call. Allowed types include `PgConnection`,
/// `PoolConnection<Postgres>` and `Transaction<Postgres>`, as well as mutable references to
/// any of these. The connection is returned if the lock could not be acquired.
///
/// The returned guard queues a `pg_advisory_unlock()` call on the connection when dropped,
/// which will be executed the next time the connection is used, or when returned to a
/// [`PgPool`][crate::postgres::PgPool] in the case of `PoolConnection<Postgres>`.
///
/// Postgres allows a single connection to acquire a given lock more than once without releasing
/// it first, so in that sense the lock is re-entrant. However, the number of unlock operations
/// must match the number of lock operations for the lock to actually be released.
///
/// See [Postgres' documentation for the Advisory Lock Functions][advisory-funcs] for details.
///
/// [advisory-funcs]: https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS
Acquires an exclusive lock using `pg_try_advisory_lock()`, returning immediately
if the lock could not be acquired.

For a version that waits until the lock is acquired, see [`Self::acquire()`].

A connection-like type is required to execute the call.



Postgres allows a single connection to acquire a given lock more than once without releasing
it first, so in that sense the lock is re-entrant. However, the number of unlock operations
must match the number of lock operations for the lock to actually be released.

See [Postgres' documentation for the Advisory Lock Functions][advisory-funcs] for details.


Acquires an exclusive lock using ` pg_try_advisory_lock () ` returning immediately if the lock could not be acquired . For a version that waits until the lock is acquired see [ ` Self :: acquire () ` ] . A connection - like type is required to execute the call . Postgres allows a single connection to acquire a given lock more than once without releasing it first so in that sense the lock is re - entrant . However the number of unlock operations must match the number of lock operations for the lock to actually be released . See [ Postgres ' documentation for the Advisory Lock Functions ] [ advisory - funcs ] for details .
pub async fn try_acquire<C: AsMut<PgConnection>>(
        &self,
        mut conn: C,
    ) -> Result<Either<PgAdvisoryLockGuard<'_, C>, C>> {
        let locked: bool = match &self.key {
            PgAdvisoryLockKey::BigInt(key) => {
                crate::query_scalar::query_scalar("SELECT pg_try_advisory_lock($1)")
                    .bind(key)
                    .fetch_one(conn.as_mut())
                    .await?
            }
            PgAdvisoryLockKey::IntPair(key1, key2) => {
                crate::query_scalar::query_scalar("SELECT pg_try_advisory_lock($1, $2)")
                    .bind(key1)
                    .bind(key2)
                    .fetch_one(conn.as_mut())
                    .await?
            }
        };
        if locked {
            Ok(Either::Left(PgAdvisoryLockGuard::new(self, conn)))
        } else {
            Ok(Either::Right(conn))
        }
    }
pub async fn try_acquire < C : AsMut < PgConnection > > ( & self , mut conn : C , ) -> Result < Either < PgAdvisoryLockGuard < ' _ , C > , C > > { let locked : bool = match & self . key { PgAdvisoryLockKey :: BigInt ( key ) => { crate :: query_scalar :: query_scalar ( " " ) . bind ( key ) . fetch_one ( conn . as_mut ( ) ) . await ? } PgAdvisoryLockKey :: IntPair ( key1 , key2 ) => { crate :: query_scalar :: query_scalar ( " " ) . bind ( key1 ) . bind ( key2 ) . fetch_one ( conn . as_mut ( ) ) . await ? } } ; if locked { Ok ( Either :: Left ( PgAdvisoryLockGuard :: new ( self , conn ) ) ) } else { Ok ( Either :: Right ( conn ) ) } }
Acquires an exclusive lock using `pg_try_advisory_lock()`, returning immediately
if the lock could not be acquired.
Acquires an exclusive lock using ` pg_try_advisory_lock () ` returning immediately if the lock could not be acquired .
&self
conn
C