|
@ -1,90 +0,0 @@ |
|
|
use std::collections::VecDeque;
|
|
|
|
|
|
use libpso::PSOPacket;
|
|
|
|
|
|
|
|
|
|
|
|
pub struct PktVec {
|
|
|
|
|
|
pkts: VecDeque<Box<dyn PSOPacket>>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl PktVec {
|
|
|
|
|
|
pub fn new() -> PktVec {
|
|
|
|
|
|
PktVec {
|
|
|
|
|
|
pkts: VecDeque::new(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn push(&mut self, pkt: Box<dyn PSOPacket>) {
|
|
|
|
|
|
self.pkts.push_back(pkt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn append(&mut self, pkts: Vec<Box<dyn PSOPacket>>) {
|
|
|
|
|
|
self.pkts.append(&mut VecDeque::from(pkts));
|
|
|
|
|
|
}
|
|
|
|
|
|
/*pub fn append(&mut self, pkts: &mut Vec<Box<dyn PSOPacket>>) {
|
|
|
|
|
|
self.pkts.append(&mut pkts.into());
|
|
|
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Iterator for PktVec {
|
|
|
|
|
|
type Item = Box<dyn PSOPacket>;
|
|
|
|
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
|
|
|
|
/*if self.index < self.pkts.len() {
|
|
|
|
|
|
let pkt = Some(self.pkts[self.index]);
|
|
|
|
|
|
self.index += 1;
|
|
|
|
|
|
pkt
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
None
|
|
|
|
|
|
}*/
|
|
|
|
|
|
self.pkts.pop_front()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
|
macro_rules! pktvec {
|
|
|
|
|
|
( $( $pkt:expr ),* ) => {
|
|
|
|
|
|
{
|
|
|
|
|
|
let mut pkts = Box::new(PktVec::new());
|
|
|
|
|
|
$(
|
|
|
|
|
|
pkts.push(Box::new($pkt));
|
|
|
|
|
|
)*
|
|
|
|
|
|
pkts
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
struct PktVecIter {
|
|
|
|
|
|
iter: Box<dyn Iterator<Item = Box<dyn PSOPacket>>>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Iterator for PktVecIter {
|
|
|
|
|
|
type Item = Box<dyn PSOPacket>;
|
|
|
|
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
|
|
|
|
self.iter.next()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct PktVec {
|
|
|
|
|
|
pkts: Vec<Box<dyn PSOPacket>>
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl PktVec {
|
|
|
|
|
|
fn push(&mut self, pkt: impl PSOPacket) {
|
|
|
|
|
|
self.pkts.push(Box::new(pkt))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn iter(&self) -> PktVecIter {
|
|
|
|
|
|
PktVecIter {
|
|
|
|
|
|
iter: self.pkts.iter()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|