pub(crate) struct Reassembler {
state: Mutex<ReassemblyState>,
timeout: Duration,
idle_timeout: Duration,
}Expand description
Reassembles fragmented messages received from untrusted peers.
Fields§
§state: Mutex<ReassemblyState>§timeout: Duration§idle_timeout: DurationImplementations§
Source§impl Reassembler
impl Reassembler
Sourcepub(crate) fn new(timeout: Duration, idle_timeout: Duration) -> Self
pub(crate) fn new(timeout: Duration, idle_timeout: Duration) -> Self
Creates a reassembler that discards incomplete messages timeout after their first
fragment, or earlier when no fragment arrives for idle_timeout. Expired messages are
discarded when the next fragment from any source arrives.
Sourcepub(super) fn original_topic(topic: Option<&str>) -> Option<Option<String>>
pub(super) fn original_topic(topic: Option<&str>) -> Option<Option<String>>
Returns None if topic does not mark a fragment, otherwise the topic of the message the
fragment belongs to.
Sourcepub(crate) fn process(
&self,
message: IncomingMessage,
) -> Option<IncomingMessage>
pub(crate) fn process( &self, message: IncomingMessage, ) -> Option<IncomingMessage>
Passes non-fragment messages through, and returns a reassembled message once its last fragment arrives. Invalid fragments are logged and dropped.
Sourcefn accept(
&self,
message: IncomingMessage,
topic: Option<String>,
now: Instant,
) -> Result<Option<IncomingMessage>, ReassemblyError>
fn accept( &self, message: IncomingMessage, topic: Option<String>, now: Instant, ) -> Result<Option<IncomingMessage>, ReassemblyError>
Appends one fragment received at now and returns the reassembled message once the last
fragment arrived. Any inconsistency discards the whole incomplete message.
Auto Trait Implementations§
impl !Freeze for Reassembler
impl RefUnwindSafe for Reassembler
impl Send for Reassembler
impl Sync for Reassembler
impl Unpin for Reassembler
impl UnsafeUnpin for Reassembler
impl UnwindSafe for Reassembler
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Consume a handle, getting back the initial
Arc<> Read more