Struct de_net::PackageBuilder
source · pub struct PackageBuilder {
reliability: Reliability,
peers: Peers,
target: SocketAddr,
buffer: Buffer,
latest: Option<Instant>,
packages: VecDeque<OutPackage>,
}
Expand description
It cumulatively builds output packages from individual messages.
Fields§
§reliability: Reliability
§peers: Peers
§target: SocketAddr
§buffer: Buffer
§latest: Option<Instant>
§packages: VecDeque<OutPackage>
Implementations§
source§impl PackageBuilder
impl PackageBuilder
pub fn new(reliability: Reliability, peers: Peers, target: SocketAddr) -> Self
sourcepub fn build_old(&mut self, threshold: Instant) -> PackageIterator<'_> ⓘ
pub fn build_old(&mut self, threshold: Instant) -> PackageIterator<'_> ⓘ
Build packages from all messages pushed before a given threshold. The last yielded package may contain newer data.
See Self::build_all
.
sourcepub fn build_all(&mut self) -> PackageIterator<'_> ⓘ
pub fn build_all(&mut self) -> PackageIterator<'_> ⓘ
Build packages from all pushed messages.
The messages are distributed among the packages in a sequential order. Each package except the last one is filled with as many messages as it can accommodate.
sourcepub fn push<E>(&mut self, message: &E, time: Instant) -> Result<(), EncodeError>where
E: Encode,
pub fn push<E>(&mut self, message: &E, time: Instant) -> Result<(), EncodeError>where
E: Encode,
Push another message to the builder so that it is included in one of the resulting packages.
It is assumed that messages are pushed in the order of their time.
§Arguments
-
message
- message to be pushed to the buffer. -
time
- time of creation of the message.
fn push_inner<E>(
&mut self,
message: &E,
time: Instant
) -> Result<(), EncodeError>where
E: Encode,
sourcefn build_package(&mut self, empty: bool)
fn build_package(&mut self, empty: bool)
Build and store another package from already buffered data (if there is any).
§Arguments
empty
- if true, newly created buffer for further messages will be empty.
Auto Trait Implementations§
impl Freeze for PackageBuilder
impl RefUnwindSafe for PackageBuilder
impl Send for PackageBuilder
impl Sync for PackageBuilder
impl Unpin for PackageBuilder
impl UnwindSafe for PackageBuilder
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