1// Copyright 2019 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45//! Main Overnet functionality.
67#![deny(missing_docs)]
89mod coding;
10mod future_help;
11mod handle_info;
12mod labels;
13mod peer;
14mod proxy;
15mod router;
16mod test_util;
1718// Export selected types from modules.
19pub use coding::{decode_fidl, encode_fidl};
20pub use future_help::log_errors;
21pub use labels::{Endpoint, NodeId, NodeLinkId};
22pub use proxy::set_proxy_drop_event_handler;
23pub use router::{AscenddClientRouting, ListPeersContext, ListablePeer, Router};
2425pub use test_util::NodeIdGenerator;
2627/// Utility trait to trace a variable to the log.
28#[allow(dead_code)]
29pub(crate) trait Trace {
30/// Trace the caller - add `msg` as text to display, and `ctx` as some context
31 /// for the system that caused this value to be traced.
32fn trace(self, msg: impl std::fmt::Display, ctx: impl std::fmt::Debug) -> Self
33where
34Self: Sized;
3536fn maybe_trace(
37self,
38 trace: bool,
39 msg: impl std::fmt::Display,
40 ctx: impl std::fmt::Debug,
41 ) -> Self
42where
43Self: Sized,
44 {
45if trace {
46self.trace(msg, ctx)
47 } else {
48self
49}
50 }
51}
5253impl<X: std::fmt::Debug> Trace for X {
54fn trace(self, msg: impl std::fmt::Display, ctx: impl std::fmt::Debug) -> Self
55where
56Self: Sized,
57 {
58log::info!("[{:?}] {}: {:?}", ctx, msg, self);
59self
60}
61}