pub struct ObserverServerBuilder { /* private fields */ }Expand description
Implementations§
Source§impl ObserverServerBuilder
impl ObserverServerBuilder
Sourcepub fn new(
bind_address: impl Into<String>,
event_handler: Arc<dyn ServerEventHandler>,
) -> Self
pub fn new( bind_address: impl Into<String>, event_handler: Arc<dyn ServerEventHandler>, ) -> Self
创建新的观察者模式构建器
§参数
bind_address: 绑定地址event_handler: 事件处理器(必须),用户只需要实现ServerEventHandler的handle_message方法即可
Sourcepub fn with_authenticator(self, authenticator: Arc<dyn Authenticator>) -> Self
pub fn with_authenticator(self, authenticator: Arc<dyn Authenticator>) -> Self
Sourcepub fn enable_auth(self) -> Self
pub fn enable_auth(self) -> Self
启用认证
Sourcepub fn with_auth_timeout(self, timeout: Duration) -> Self
pub fn with_auth_timeout(self, timeout: Duration) -> Self
设置认证超时时间
Sourcepub fn with_device_manager(self, device_manager: Arc<DeviceManager>) -> Self
pub fn with_device_manager(self, device_manager: Arc<DeviceManager>) -> Self
设置设备管理器(用于设备冲突管理)
Sourcepub fn with_connection_manager(self, manager: Arc<ConnectionManager>) -> Self
pub fn with_connection_manager(self, manager: Arc<ConnectionManager>) -> Self
设置连接管理器(可选,用于共享连接状态)
Sourcepub fn with_protocol(self, protocol: TransportProtocol) -> Self
pub fn with_protocol(self, protocol: TransportProtocol) -> Self
设置传输协议
Sourcepub fn with_protocols(self, protocols: Vec<TransportProtocol>) -> Self
pub fn with_protocols(self, protocols: Vec<TransportProtocol>) -> Self
启用多协议监听
Sourcepub fn with_protocol_address(
self,
protocol: TransportProtocol,
address: String,
) -> Self
pub fn with_protocol_address( self, protocol: TransportProtocol, address: String, ) -> Self
为特定协议设置监听地址
Sourcepub fn with_max_connections(self, max: usize) -> Self
pub fn with_max_connections(self, max: usize) -> Self
设置最大连接数
Sourcepub fn with_handshake_timeout(self, timeout: Duration) -> Self
pub fn with_handshake_timeout(self, timeout: Duration) -> Self
设置握手超时时间
Sourcepub fn with_max_handshake_concurrency(self, max: usize) -> Self
pub fn with_max_handshake_concurrency(self, max: usize) -> Self
设置最大并发握手数
Sourcepub fn with_write_timeout(self, timeout: Duration) -> Self
pub fn with_write_timeout(self, timeout: Duration) -> Self
设置单次连接写入超时时间
Sourcepub fn with_fanout_concurrency(self, max: usize) -> Self
pub fn with_fanout_concurrency(self, max: usize) -> Self
设置 fanout 发送最大并发度
Sourcepub fn with_heartbeat(self, heartbeat: HeartbeatConfig) -> Self
pub fn with_heartbeat(self, heartbeat: HeartbeatConfig) -> Self
设置心跳配置
Sourcepub fn with_default_format(self, format: SerializationFormat) -> Self
pub fn with_default_format(self, format: SerializationFormat) -> Self
设置默认序列化格式(用于协商,默认 Protobuf)
Sourcepub fn with_default_compression(self, compression: CompressionAlgorithm) -> Self
pub fn with_default_compression(self, compression: CompressionAlgorithm) -> Self
设置默认压缩算法(用于协商,默认 None)
Auto Trait Implementations§
impl !RefUnwindSafe for ObserverServerBuilder
impl !UnwindSafe for ObserverServerBuilder
impl Freeze for ObserverServerBuilder
impl Send for ObserverServerBuilder
impl Sync for ObserverServerBuilder
impl Unpin for ObserverServerBuilder
impl UnsafeUnpin for ObserverServerBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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