Skip to main content

miden_node_utils/
grpc.rs

1use std::net::SocketAddr;
2
3use anyhow::Context;
4
5/// Maximum encoded bytes accepted in a gRPC message unless explicitly configured.
6pub const DEFAULT_MAX_DECODING_MESSAGE_SIZE: usize = 4 * 1024 * 1024;
7
8/// A sealed extension trait for [`url::Url`] that adds convenience functions for binding and
9/// connecting to the url.
10pub trait UrlExt: private::Sealed {
11    fn to_socket(&self) -> anyhow::Result<SocketAddr>;
12}
13
14impl UrlExt for url::Url {
15    fn to_socket(&self) -> anyhow::Result<SocketAddr> {
16        self.socket_addrs(|| None)?
17            .into_iter()
18            .next()
19            .with_context(|| format!("failed to convert url {self} to socket address"))
20    }
21}
22
23mod private {
24    pub trait Sealed {}
25    impl Sealed for url::Url {}
26}
27
28mod server;
29pub use server::{server_builder, tcp_incoming};