From 1b538455fcf8697c6ddd2d707e464459b38d2782 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Wed, 4 Dec 2024 21:50:47 +0000 Subject: [PATCH] deploy: e5d135a97a4da952762e41c9ac9ebd27bbe3a3c2 --- pr/3010/docs/iroh/protocol/index.html | 7 +++---- pr/3010/docs/iroh/protocol/struct.ProtocolMap.html | 12 ++++++------ pr/3010/docs/iroh/protocol/struct.Router.html | 12 ++++++------ pr/3010/docs/iroh/protocol/struct.RouterBuilder.html | 12 ++++++------ .../docs/iroh/protocol/trait.ProtocolHandler.html | 6 +++--- pr/3010/docs/src/iroh/protocol.rs.html | 8 ++------ 6 files changed, 26 insertions(+), 31 deletions(-) diff --git a/pr/3010/docs/iroh/protocol/index.html b/pr/3010/docs/iroh/protocol/index.html index dc8b13a23e..018a6706c8 100644 --- a/pr/3010/docs/iroh/protocol/index.html +++ b/pr/3010/docs/iroh/protocol/index.html @@ -1,10 +1,9 @@ -iroh::protocol - Rust

Module iroh::protocol

source ·
Expand description

Tools for spawning an accept loop that routes incoming requests to the right protocol.

+iroh::protocol - Rust

Module iroh::protocol

source ·
Expand description

Tools for spawning an accept loop that routes incoming requests to the right protocol.

§Example

let endpoint = Endpoint::builder().discovery_n0().bind().await?;
 
-const ALPN: &[u8] = b"/my/alpn";
 let router = Router::builder(endpoint)
-    .accept(&ALPN, Arc::new(Echo))
+    .accept(b"/my/alpn", Echo)
     .spawn()
     .await?;
 
@@ -13,7 +12,7 @@
 struct Echo;
 
 impl ProtocolHandler for Echo {
-    fn accept(self: Arc<Self>, connecting: Connecting) -> BoxedFuture<Result<()>> {
+    fn accept(&self, connecting: Connecting) -> BoxedFuture<Result<()>> {
         Box::pin(async move {
             let connection = connecting.await?;
             let (mut send, mut recv) = connection.accept_bi().await?;
diff --git a/pr/3010/docs/iroh/protocol/struct.ProtocolMap.html b/pr/3010/docs/iroh/protocol/struct.ProtocolMap.html
index 86a41dbef4..3771075c5a 100644
--- a/pr/3010/docs/iroh/protocol/struct.ProtocolMap.html
+++ b/pr/3010/docs/iroh/protocol/struct.ProtocolMap.html
@@ -1,10 +1,10 @@
-ProtocolMap in iroh::protocol - Rust

Struct iroh::protocol::ProtocolMap

source ·
pub struct ProtocolMap(/* private fields */);
Expand description

A typed map of protocol handlers, mapping them from ALPNs.

-

Implementations§

source§

impl ProtocolMap

source

pub fn get(&self, alpn: &[u8]) -> Option<&dyn ProtocolHandler>

Returns the registered protocol handler for an ALPN as a Arc<dyn ProtocolHandler>.

-
source

pub fn insert(&mut self, alpn: Vec<u8>, handler: impl ProtocolHandler)

Inserts a protocol handler.

-
source

pub fn alpns(&self) -> impl Iterator<Item = &Vec<u8>>

Returns an iterator of all registered ALPN protocol identifiers.

-
source

pub async fn shutdown(&self)

Shuts down all protocol handlers.

+ProtocolMap in iroh::protocol - Rust

Struct iroh::protocol::ProtocolMap

source ·
pub struct ProtocolMap(/* private fields */);
Expand description

A typed map of protocol handlers, mapping them from ALPNs.

+

Implementations§

source§

impl ProtocolMap

source

pub fn get(&self, alpn: &[u8]) -> Option<&dyn ProtocolHandler>

Returns the registered protocol handler for an ALPN as a Arc<dyn ProtocolHandler>.

+
source

pub fn insert(&mut self, alpn: Vec<u8>, handler: impl ProtocolHandler)

Inserts a protocol handler.

+
source

pub fn alpns(&self) -> impl Iterator<Item = &Vec<u8>>

Returns an iterator of all registered ALPN protocol identifiers.

+
source

pub async fn shutdown(&self)

Shuts down all protocol handlers.

Calls and awaits ProtocolHandler::shutdown for all registered handlers concurrently.

-

Trait Implementations§

source§

impl Debug for ProtocolMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ProtocolMap

source§

fn default() -> ProtocolMap

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where +

Trait Implementations§

source§

impl Debug for ProtocolMap

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ProtocolMap

source§

fn default() -> ProtocolMap

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( diff --git a/pr/3010/docs/iroh/protocol/struct.Router.html b/pr/3010/docs/iroh/protocol/struct.Router.html index 1b04d2cf8a..9b05eb59d2 100644 --- a/pr/3010/docs/iroh/protocol/struct.Router.html +++ b/pr/3010/docs/iroh/protocol/struct.Router.html @@ -1,4 +1,4 @@ -Router in iroh::protocol - Rust

Struct iroh::protocol::Router

source ·
pub struct Router { /* private fields */ }
Expand description

The built router.

+Router in iroh::protocol - Rust

Struct iroh::protocol::Router

source ·
pub struct Router { /* private fields */ }
Expand description

The built router.

Construct this using Router::builder.

When dropped, this will abort listening the tasks, so make sure to store it.

Even with this abort-on-drop behaviour, it’s recommended to call and await @@ -16,16 +16,16 @@ wait for [tokio::signal::ctrl_c()]:

// wait until the user wants to tokio::signal::ctrl_c().await?; router.shutdown().await?;

-

Implementations§

source§

impl Router

source

pub fn builder(endpoint: Endpoint) -> RouterBuilder

Creates a new Router using given Endpoint.

-
source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint stored in this router.

-
source

pub fn is_shutdown(&self) -> bool

Checks if the router is already shutdown.

-
source

pub async fn shutdown(&self) -> Result<()>

Shuts down the accept loop cleanly.

+

Implementations§

source§

impl Router

source

pub fn builder(endpoint: Endpoint) -> RouterBuilder

Creates a new Router using given Endpoint.

+
source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint stored in this router.

+
source

pub fn is_shutdown(&self) -> bool

Checks if the router is already shutdown.

+
source

pub async fn shutdown(&self) -> Result<()>

Shuts down the accept loop cleanly.

When this function returns, all ProtocolHandlers will be shutdown and Endpoint::close will have been called.

If already shutdown, it returns Ok.

If some ProtocolHandler panicked in the accept loop, this will propagate that panic into the result here.

-

Trait Implementations§

source§

impl Clone for Router

source§

fn clone(&self) -> Router

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Router

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Router

§

impl !RefUnwindSafe for Router

§

impl Send for Router

§

impl Sync for Router

§

impl Unpin for Router

§

impl !UnwindSafe for Router

Blanket Implementations§

source§

impl<T> Any for T
where +

Trait Implementations§

source§

impl Clone for Router

source§

fn clone(&self) -> Router

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Router

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Router

§

impl !RefUnwindSafe for Router

§

impl Send for Router

§

impl Sync for Router

§

impl Unpin for Router

§

impl !UnwindSafe for Router

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( diff --git a/pr/3010/docs/iroh/protocol/struct.RouterBuilder.html b/pr/3010/docs/iroh/protocol/struct.RouterBuilder.html index 85a219505e..4fada4cbac 100644 --- a/pr/3010/docs/iroh/protocol/struct.RouterBuilder.html +++ b/pr/3010/docs/iroh/protocol/struct.RouterBuilder.html @@ -1,14 +1,14 @@ -RouterBuilder in iroh::protocol - Rust

Struct iroh::protocol::RouterBuilder

source ·
pub struct RouterBuilder { /* private fields */ }
Expand description

Builder for creating a Router for accepting protocols.

-

Implementations§

source§

impl RouterBuilder

source

pub fn new(endpoint: Endpoint) -> Self

Creates a new router builder using given Endpoint.

-
source

pub fn accept( +RouterBuilder in iroh::protocol - Rust

Struct iroh::protocol::RouterBuilder

source ·
pub struct RouterBuilder { /* private fields */ }
Expand description

Builder for creating a Router for accepting protocols.

+

Implementations§

source§

impl RouterBuilder

source

pub fn new(endpoint: Endpoint) -> Self

Creates a new router builder using given Endpoint.

+
source

pub fn accept( self, alpn: impl AsRef<[u8]>, handler: impl ProtocolHandler ) -> Self

Configures the router to accept the ProtocolHandler when receiving a connection with this alpn.

-
source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint of the node.

-
source

pub async fn spawn(self) -> Result<Router>

Spawns an accept loop and returns a handle to it encapsulated as the Router.

-

Trait Implementations§

source§

impl Debug for RouterBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where +

source

pub fn endpoint(&self) -> &Endpoint

Returns the Endpoint of the node.

+
source

pub async fn spawn(self) -> Result<Router>

Spawns an accept loop and returns a handle to it encapsulated as the Router.

+

Trait Implementations§

source§

impl Debug for RouterBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( diff --git a/pr/3010/docs/iroh/protocol/trait.ProtocolHandler.html b/pr/3010/docs/iroh/protocol/trait.ProtocolHandler.html index 89afd26248..0595597756 100644 --- a/pr/3010/docs/iroh/protocol/trait.ProtocolHandler.html +++ b/pr/3010/docs/iroh/protocol/trait.ProtocolHandler.html @@ -1,4 +1,4 @@ -ProtocolHandler in iroh::protocol - Rust

Trait iroh::protocol::ProtocolHandler

source ·
pub trait ProtocolHandler: Send + Sync + Debug + 'static {
+ProtocolHandler in iroh::protocol - Rust

Trait iroh::protocol::ProtocolHandler

source ·
pub trait ProtocolHandler: Send + Sync + Debug + 'static {
     // Required method
     fn accept(&self, conn: Connecting) -> BoxedFuture<Result<()>>;
 
@@ -10,7 +10,7 @@
 

Implement this trait on a struct that should handle incoming connections. The protocol handler must then be registered on the node for an ALPN protocol with crate::protocol::RouterBuilder::accept.

-

Required Methods§

source

fn accept(&self, conn: Connecting) -> BoxedFuture<Result<()>>

Handle an incoming connection.

+

Required Methods§

source

fn accept(&self, conn: Connecting) -> BoxedFuture<Result<()>>

Handle an incoming connection.

This runs on a freshly spawned tokio task so this can be long-running.

-

Provided Methods§

source

fn shutdown(&self) -> BoxedFuture<()>

Called when the node shuts down.

+

Provided Methods§

source

fn shutdown(&self) -> BoxedFuture<()>

Called when the node shuts down.

Implementors§

\ No newline at end of file diff --git a/pr/3010/docs/src/iroh/protocol.rs.html b/pr/3010/docs/src/iroh/protocol.rs.html index e81cb29ce9..7d1491928b 100644 --- a/pr/3010/docs/src/iroh/protocol.rs.html +++ b/pr/3010/docs/src/iroh/protocol.rs.html @@ -353,14 +353,11 @@ 353 354 355 -356 -357

//! Tools for spawning an accept loop that routes incoming requests to the right protocol.
 //!
 //! ## Example
 //!
 //! ```no_run
-//! # use std::sync::Arc;
 //! # use anyhow::Result;
 //! # use futures_lite::future::Boxed as BoxedFuture;
 //! # use iroh::{endpoint::Connecting, protocol::{ProtocolHandler, Router}, Endpoint, NodeAddr};
@@ -368,9 +365,8 @@
 //! # async fn test_compile() -> Result<()> {
 //! let endpoint = Endpoint::builder().discovery_n0().bind().await?;
 //!
-//! const ALPN: &[u8] = b"/my/alpn";
 //! let router = Router::builder(endpoint)
-//!     .accept(&ALPN, Arc::new(Echo))
+//!     .accept(b"/my/alpn", Echo)
 //!     .spawn()
 //!     .await?;
 //! # Ok(())
@@ -381,7 +377,7 @@
 //! struct Echo;
 //!
 //! impl ProtocolHandler for Echo {
-//!     fn accept(self: Arc<Self>, connecting: Connecting) -> BoxedFuture<Result<()>> {
+//!     fn accept(&self, connecting: Connecting) -> BoxedFuture<Result<()>> {
 //!         Box::pin(async move {
 //!             let connection = connecting.await?;
 //!             let (mut send, mut recv) = connection.accept_bi().await?;