1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2026 DeRec Alliance. All rights reserved.
//! Behaviour attached to types this crate does not own.
//!
//! Almost everything the protocol reads off the wire is a `derec-proto` type,
//! and every one of them is generated. An inherent `impl` on a foreign type is
//! impossible, so the behaviour that belongs *to* a message — validating it,
//! reading what it advertises, converting it to the shape the core protocol
//! uses — is attached through an extension trait instead.
//!
//! One file per trait, named for the type it extends. Bring a trait into scope
//! at the call site (`use crate::extensions::contact_message::ContactMessageExt
//! as _;`) and call the methods on the value itself.
//!
//! # Why these are traits and not free functions
//!
//! A free `validate(&contact)` is a function a new call site can forget to
//! call. `contact.validate()?` reads as part of handling the message, sits in
//! autocomplete next to the type's own fields, and puts the rule in one place
//! rather than once per reader — which is what each of these replaced.
//!
//! # The one trait here that does not extend a proto type
//!
//! `channel_store` extends [`DeRecChannelStore`](crate::protocol::DeRecChannelStore),
//! a trait this crate defines and applications implement. It is here because
//! it is the same pattern for the same reason — behaviour that cannot be an
//! inherent `impl`, since the implementing type belongs to the application.
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub