pub struct RouteConnectionService { /* private fields */ }Expand description
RouteConnectionService 适配器
将 Route 适配为 ConnectionService,负责处理网络连接并将其转发到路由系统。
§设计理念
- 职责分离: Route 专注于路由逻辑,RouteConnectionService 专注于连接处理
- 适配器模式: 通过适配器解耦路由层与网络服务层
- 向后兼容: Route 直接实现 ConnectionService 委托给此适配器
§示例
use silent::prelude::*;
let route = Route::new("").get(|_req: Request| async { Ok("hello world") });
// 直接使用 Route(推荐)
Server::new().run(route);Implementations§
Trait Implementations§
Source§impl Clone for RouteConnectionService
impl Clone for RouteConnectionService
Source§fn clone(&self) -> RouteConnectionService
fn clone(&self) -> RouteConnectionService
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ConnectionService for RouteConnectionService
impl ConnectionService for RouteConnectionService
Source§fn call(
&self,
stream: BoxedConnection,
peer: CoreSocketAddr,
) -> ConnectionFuture
fn call( &self, stream: BoxedConnection, peer: CoreSocketAddr, ) -> ConnectionFuture
处理单个网络连接。 Read more
Auto Trait Implementations§
impl Freeze for RouteConnectionService
impl !RefUnwindSafe for RouteConnectionService
impl Send for RouteConnectionService
impl Sync for RouteConnectionService
impl Unpin for RouteConnectionService
impl !UnwindSafe for RouteConnectionService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more