# `RequestSeal.Custody.Context`
[🔗](https://github.com/baselabs/request_seal/blob/v0.5.2/lib/request_seal/custody/context.ex#L1)

Absolute monotonic millisecond deadline and original caller PID.

Custodians propagate `deadline` to all external work and honor caller death as
cancellation. The custody boundary also terminates its worker on either event.
Closing a client connection does not undo a signature already produced by a peer.

# `t`

```elixir
@type t() :: %RequestSeal.Custody.Context{deadline: integer(), owner: pid()}
```

# `remaining`

```elixir
@spec remaining(t()) :: non_neg_integer()
```

Remaining operation milliseconds; zero means the deadline has expired.

## Parameters

  * `context` - a `t:t/0` whose `deadline` is an integer in
    `System.monotonic_time(:millisecond)` units.

## Returns

  * a non-negative integer: `deadline` minus the current monotonic time in
    milliseconds, or `0` once the deadline has passed. This function returns
    no error tuple; an argument that is not a context struct raises
    `FunctionClauseError`.

## Examples

    iex> context = %RequestSeal.Custody.Context{owner: self(), deadline: System.monotonic_time(:millisecond) + 5_000}
    iex> RequestSeal.Custody.Context.remaining(context) in 1..5_000
    true
    iex> expired = %RequestSeal.Custody.Context{owner: self(), deadline: System.monotonic_time(:millisecond) - 10}
    iex> RequestSeal.Custody.Context.remaining(expired)
    0

---

*Consult [api-reference.md](api-reference.md) for complete listing*
