async fn do_transaction<T, R>(engine: EngineProxy, cb: T) -> Result<(), EditTransactionError>
where
    T: Fn(EditTransactionProxy) -> R,
    R: Future<Output = Result<EditTransactionProxy, fidl::Error>>,
{
    // Make a reasonable effort to retry the edit after a concurrent edit, but don't retry forever.
    for _ in 0..100 {
        let (transaction, transaction_server_end) = fidl::endpoints::create_proxy()?;
        engine.start_edit_transaction(transaction_server_end)?;

        let transaction = await!(cb(transaction))?;

        let status = await!(transaction.commit())?;

        // Retry edit transaction on concurrent edit
        return match zx::Status::from_raw(status) {
            zx::Status::OK => Ok(()),
            zx::Status::UNAVAILABLE => {
                continue;
            }
            status => Err(EditTransactionError::CommitError(status)),
        };
    }

    Err(EditTransactionError::CommitError(zx::Status::UNAVAILABLE))
}
/// Perform a rewrite rule edit transaction, retrying as necessary if another edit transaction runs
/// concurrently.
///
/// The given callback `cb` should perform the needed edits to the state of the rewrite rules but
/// not attempt to `commit()` the transaction. `do_transaction` will internally attempt to commit
/// the transaction and trigger a retry if necessary.
Perform a rewrite rule edit transaction, retrying as necessary if another edit transaction runs
concurrently.

The given callback `cb` should perform the needed edits to the state of the rewrite rules but
not attempt to `commit()` the transaction. `do_transaction` will internally attempt to commit
the transaction and trigger a retry if necessary.
Perform a rewrite rule edit transaction retrying as necessary if another edit transaction runs concurrently . The given callback ` cb ` should perform the needed edits to the state of the rewrite rules but not attempt to ` commit () ` the transaction . ` do_transaction ` will internally attempt to commit the transaction and trigger a retry if necessary .
async fn do_transaction<T, R>(engine: EngineProxy, cb: T) -> Result<(), EditTransactionError>
where
    T: Fn(EditTransactionProxy) -> R,
    R: Future<Output = Result<EditTransactionProxy, fidl::Error>>,
{
    // Make a reasonable effort to retry the edit after a concurrent edit, but don't retry forever.
    for _ in 0..100 {
        let (transaction, transaction_server_end) = fidl::endpoints::create_proxy()?;
        engine.start_edit_transaction(transaction_server_end)?;
        let transaction = await!(cb(transaction))?;
        let status = await!(transaction.commit())?;
        // Retry edit transaction on concurrent edit
        return match zx::Status::from_raw(status) {
            zx::Status::OK => Ok(()),
            zx::Status::UNAVAILABLE => {
                continue;
            }
            status => Err(EditTransactionError::CommitError(status)),
        };
    }
    Err(EditTransactionError::CommitError(zx::Status::UNAVAILABLE))
}
async fn do_transaction < T , R > ( engine : EngineProxy , cb : T ) -> Result < ( ) , EditTransactionError > where T : Fn ( EditTransactionProxy ) -> R , R : Future < Output = Result < EditTransactionProxy , fidl :: Error > > , { // Make a reasonable effort to retry the edit after a concurrent edit, but don't retry forever. for _ in 0 .. 100 { let ( transaction , transaction_server_end ) = fidl :: endpoints :: create_proxy ( ) ? ; engine . start_edit_transaction ( transaction_server_end ) ? ; let transaction = await ! ( cb ( transaction ) ) ? ; let status = await ! ( transaction commit ( ) ) ? ; // Retry edit transaction on concurrent edit return match zx :: Status :: from_raw ( status ) { zx :: Status :: OK => Ok ( ( ) ) , zx :: Status :: UNAVAILABLE => { continue ; } status => Err ( EditTransactionError :: CommitError ( status ) ) , } ; } Err ( EditTransactionError :: CommitError ( zx :: Status :: UNAVAILABLE ) ) }
Perform a rewrite rule edit transaction, retrying as necessary if another edit transaction runs
concurrently.
Perform a rewrite rule edit transaction retrying as necessary if another edit transaction runs concurrently .
engine
EngineProxy
cb
T
engine
EngineProxy
cb
T