Refactor
This commit is contained in:
@@ -47,13 +47,16 @@ impl Stream for InputMerge {
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
use Poll::*;
|
||||
let selfp = self.project();
|
||||
let ret = {
|
||||
if let Some(inp) = selfp.inp3.as_pin_mut() {
|
||||
let mut selfp = self.as_mut().project();
|
||||
if let Some(inp) = selfp.inp3.as_mut().as_pin_mut() {
|
||||
match inp.poll_next(cx) {
|
||||
Ready(Some(x)) => Some(CaConnSetEvent::ConnSetCmd(todo!())),
|
||||
Ready(None) => {
|
||||
// self.inp3 = None;
|
||||
unsafe {
|
||||
// TODO what guarantees that I can drop the content here like this?
|
||||
self.as_mut().get_unchecked_mut().inp3 = None;
|
||||
}
|
||||
None
|
||||
}
|
||||
Pending => None,
|
||||
@@ -65,11 +68,15 @@ impl Stream for InputMerge {
|
||||
let ret = if let Some(x) = ret {
|
||||
Some(x)
|
||||
} else {
|
||||
if let Some(inp) = selfp.inp2.as_pin_mut() {
|
||||
let mut selfp = self.as_mut().project();
|
||||
if let Some(inp) = selfp.inp2.as_mut().as_pin_mut() {
|
||||
match inp.poll_next(cx) {
|
||||
Ready(Some(x)) => Some(CaConnSetEvent::ConnSetCmd(todo!())),
|
||||
Ready(None) => {
|
||||
// self.inp2 = None;
|
||||
unsafe {
|
||||
// TODO what guarantees that I can drop the content here like this?
|
||||
self.as_mut().get_unchecked_mut().inp2 = None;
|
||||
}
|
||||
None
|
||||
}
|
||||
Pending => None,
|
||||
@@ -81,11 +88,15 @@ impl Stream for InputMerge {
|
||||
if let Some(x) = ret {
|
||||
Ready(Some(x))
|
||||
} else {
|
||||
if let Some(inp) = selfp.inp1.as_pin_mut() {
|
||||
let mut selfp = self.as_mut().project();
|
||||
if let Some(inp) = selfp.inp1.as_mut().as_pin_mut() {
|
||||
match inp.poll_next(cx) {
|
||||
Ready(Some(x)) => Ready(Some(x)),
|
||||
Ready(None) => {
|
||||
// self.inp1 = None;
|
||||
unsafe {
|
||||
// TODO what guarantees that I can drop the content here like this?
|
||||
self.as_mut().get_unchecked_mut().inp1 = None;
|
||||
}
|
||||
Ready(None)
|
||||
}
|
||||
Pending => Pending,
|
||||
|
||||
@@ -217,7 +217,7 @@ async fn finder_worker_single(
|
||||
items.extend(to_add.into_iter());
|
||||
let items = items;
|
||||
for e in &items {
|
||||
if crate::ca::connset::trigger.contains(&e.channel.as_str()) {
|
||||
if true || crate::ca::connset::trigger.contains(&e.channel.as_str()) {
|
||||
debug!("found in database: {e:?}");
|
||||
}
|
||||
}
|
||||
@@ -262,6 +262,7 @@ async fn finder_network_if_not_found(
|
||||
let mut res = VecDeque::new();
|
||||
let mut net = VecDeque::new();
|
||||
for e in item {
|
||||
trace!("finder_network_if_not_found sees {e:?}");
|
||||
if e.addr.is_none() {
|
||||
net.push_back(e.channel);
|
||||
} else {
|
||||
|
||||
@@ -402,13 +402,14 @@ impl CaMsgTy {
|
||||
|
||||
fn payload_len(&self) -> usize {
|
||||
use CaMsgTy::*;
|
||||
trace!("payload_len for {self:?}");
|
||||
match self {
|
||||
Version => 0,
|
||||
VersionRes(_) => 0,
|
||||
Error(x) => (16 + x.msg.len() + 1 + 7) / 8 * 8,
|
||||
ClientName => 0x10,
|
||||
ClientNameRes(x) => (x.name.len() + 1 + 7) / 8 * 8,
|
||||
HostName(_) => 0x18,
|
||||
HostName(x) => (x.len() + 1 + 7) / 8 * 8,
|
||||
Search(x) => (x.channel.len() + 1 + 7) / 8 * 8,
|
||||
SearchRes(_) => 8,
|
||||
CreateChan(x) => (x.channel.len() + 1 + 7) / 8 * 8,
|
||||
|
||||
Reference in New Issue
Block a user