pub async fn now_once(url: Option<Url2>) -> crate::types::actor::KitsuneP2pResult<u64> {
    match NOW_OFFSET_MILLIS.get() {
        Some(offset) => Ok(u64::try_from(i64::try_from(local_now()?)? + offset)?),
        None => {
            let offset: i64 = match now(url.clone()).await {
                Ok(v) => {
                    let offset = v as i64 - local_now()? as i64;
                    match NOW_OFFSET_MILLIS.set(offset) {
                        Ok(_) => offset,
                        Err(v) => v,
                    }
                }
                // @todo Do something more sophisticated here with errors.
                // Currently just falls back to a zero offset if the server is not happy.
                Err(_) => {
                    let offset = 0;
                    match NOW_OFFSET_MILLIS.set(offset) {
                        Ok(_) => offset,
                        Err(v) => v,
                    }
                }
            };

            Ok(u64::try_from(i64::try_from(local_now()?)? + offset)?)
        }
    }
}
/// Thick wrapper around `do_api` for the `now` op.
///
/// Calculates the offset on the first call and caches it in the cell above.
/// Only calls `now` once then keeps the offset for the static lifetime.
Thick wrapper around `do_api` for the `now` op.
Calculates the offset on the first call and caches it in the cell above.
Only calls `now` once then keeps the offset for the static lifetime.
Thick wrapper around ` do_api ` for the ` now ` op . Calculates the offset on the first call and caches it in the cell above . Only calls ` now ` once then keeps the offset for the static lifetime .
pub async fn now_once(url: Option<Url2>) -> crate::types::actor::KitsuneP2pResult<u64> {
    match NOW_OFFSET_MILLIS.get() {
        Some(offset) => Ok(u64::try_from(i64::try_from(local_now()?)? + offset)?),
        None => {
            let offset: i64 = match now(url.clone()).await {
                Ok(v) => {
                    let offset = v as i64 - local_now()? as i64;
                    match NOW_OFFSET_MILLIS.set(offset) {
                        Ok(_) => offset,
                        Err(v) => v,
                    }
                }
                // @todo Do something more sophisticated here with errors.
                // Currently just falls back to a zero offset if the server is not happy.
                Err(_) => {
                    let offset = 0;
                    match NOW_OFFSET_MILLIS.set(offset) {
                        Ok(_) => offset,
                        Err(v) => v,
                    }
                }
            };
            Ok(u64::try_from(i64::try_from(local_now()?)? + offset)?)
        }
    }
}
pub async fn now_once ( url : Option < Url2 > ) -> crate :: types :: actor :: KitsuneP2pResult < u64 > { match NOW_OFFSET_MILLIS . get ( ) { Some ( offset ) => Ok ( u64 :: try_from ( i64 :: try_from ( local_now ( ) ? ) ? + offset ) ? ) , None => { let offset : i64 = match now ( url . clone ( ) ) . await { Ok ( v ) => { let offset = v as i64 - local_now ( ) ? as i64 ; match NOW_OFFSET_MILLIS . set ( offset ) { Ok ( _ ) => offset , Err ( v ) => v , } } // @todo Do something more sophisticated here with errors. // Currently just falls back to a zero offset if the server is not happy. Err ( _ ) => { let offset = 0 ; match NOW_OFFSET_MILLIS . set ( offset ) { Ok ( _ ) => offset , Err ( v ) => v , } } } ; Ok ( u64 :: try_from ( i64 :: try_from ( local_now ( ) ? ) ? + offset ) ? ) } } }
Thick wrapper around `do_api` for the `now` op.
Thick wrapper around ` do_api ` for the ` now ` op .
url
Option<Url2>
url
Option<Url2>