# Design

> The interface is a thin layer over UCall's native library, and every rule below follows from that.

`#include <ucall/types.hpp>` 1.0.0-rc.1 · b7577426

The interface is a thin layer over UCall’s native library, and every rule below follows from that.

- **Verbs share one name across languages.** `take_call`, `take_calls`, `take_batch`, `take_batches`, `submit` and `take_completed` name the same calls in C++, Go, Python and Rust.
- **Blocking stays simple, deferring stays symmetric.** A reply that is final on return answers a `status_t`, and one that may finish later answers a `deferred` that `wait` s, is awaited through `co_await call.wait(loop)`, or waits as it is destroyed, as Rust’s `Deferred` does when dropped.
- **Ownership is a type, not a flag.** A reply takes its `request_t`, a destroyed request answers 500, a `response_t` frees itself, and a `deferred` never moves, so the stack or the coroutine frame holding it outlives the call.
- **Handlers stay the caller’s, never boxed.** A function or a member is a template argument and an object or a callable with state stays the caller’s until the server or client is destroyed, so registration copies no closure, and every handler is `noexcept`, as no fault can unwind through the library.
- **Polling allocates nothing.** Blocking verbs keep their outcome on the stack, a deferred call keeps it inside itself, and an awaiter posts two words, a function and its own address, into the caller’s scheduler, as Rust’s waker does. A server and a client hold their handles alone: the library hands each callback its server, and a blocking call takes its own completion out of the library’s queue.
- **No life of its own.** The interface starts no threads, keeps no global state and needs no runtime, so it drops into any threading model.

| Path | Rust | C++ |
| - | - | - |
| Blocking verb | 0 | 0 |
| Each handler call | 0 | 0 |
| Deferred reply or pull | 0 | 0, the `deferred` lives in the caller |
| Await | 0 | 0 in the binding |
| Route registration | 1 `Box` | 0 |
| Client start | call tables | 0 |

## API

### Types

#### `owner`

Owns one handle of `handle_type_`, which `free_` releases, moving it and never copying it.

[types.hpp:240 ↗](https://github.com/unum-cloud/UCall/blob/b75774266a108d8a1b1a6db1489f8a7141c556df/cpp/ucall/types.hpp#L240)

```cpp
template <typename handle_type_,
          void(*)(handle_type_) free_>
class owner
```
