msg_deadline

Function msg_deadline 

Source
pub fn msg_deadline() -> Option<NonZeroU64>
Expand description

Gets the deadline, in nanoseconds since 1970-01-01, after which the caller might stop waiting for a response.

For calls to update methods with best-effort responses and their callbacks, the deadline is computed based on the time the call was made, and the timeout_seconds parameter provided by the caller. In such cases, the deadline value will be converted to NonZeroU64 and wrapped in Some. To get the deadline value as a u64, call get() on the NonZeroU64 value.

use ic_cdk::api::msg_deadline;
if let Some(deadline) = msg_deadline() {
    let deadline_value : u64 = deadline.get();
}

For other calls (ingress messages and all calls to query and composite query methods, including calls in replicated mode), a None is returned. Please note that the raw msg_deadline system API returns 0 in such cases. This function is a wrapper around the raw system API that provides more semantic information through the return type.