filtering cleanup
This commit is contained in:
25
veilid-core/src/rpc_processor/coders/address_type_set.rs
Normal file
25
veilid-core/src/rpc_processor/coders/address_type_set.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use crate::*;
|
||||
use rpc_processor::*;
|
||||
|
||||
pub fn encode_address_type_set(
|
||||
address_type_set: &AddressTypeSet,
|
||||
builder: &mut veilid_capnp::address_type_set::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_ipv4(address_type_set.contains(AddressType::IPV4));
|
||||
builder.set_ipv6(address_type_set.contains(AddressType::IPV6));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn decode_address_type_set(
|
||||
reader: &veilid_capnp::address_type_set::Reader,
|
||||
) -> Result<AddressTypeSet, RPCError> {
|
||||
let mut out = AddressTypeSet::new();
|
||||
if reader.reborrow().get_ipv4() {
|
||||
out.insert(AddressType::IPV4);
|
||||
}
|
||||
if reader.reborrow().get_ipv6() {
|
||||
out.insert(AddressType::IPV6);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
mod address;
|
||||
mod address_type_set;
|
||||
mod block_id;
|
||||
mod dial_info;
|
||||
mod dial_info_class;
|
||||
@@ -11,7 +12,7 @@ mod nonce;
|
||||
mod operations;
|
||||
mod peer_info;
|
||||
mod private_safety_route;
|
||||
mod protocol_set;
|
||||
mod protocol_type_set;
|
||||
mod public_key;
|
||||
mod sender_info;
|
||||
mod signal_info;
|
||||
@@ -23,6 +24,7 @@ mod value_data;
|
||||
mod value_key;
|
||||
|
||||
pub use address::*;
|
||||
pub use address_type_set::*;
|
||||
pub use block_id::*;
|
||||
pub use dial_info::*;
|
||||
pub use dial_info_class::*;
|
||||
@@ -35,7 +37,7 @@ pub use nonce::*;
|
||||
pub use operations::*;
|
||||
pub use peer_info::*;
|
||||
pub use private_safety_route::*;
|
||||
pub use protocol_set::*;
|
||||
pub use protocol_type_set::*;
|
||||
pub use public_key::*;
|
||||
pub use sender_info::*;
|
||||
pub use signal_info::*;
|
||||
|
@@ -8,7 +8,10 @@ pub fn encode_node_info(
|
||||
builder.set_network_class(encode_network_class(node_info.network_class));
|
||||
|
||||
let mut ps_builder = builder.reborrow().init_outbound_protocols();
|
||||
encode_protocol_set(&node_info.outbound_protocols, &mut ps_builder)?;
|
||||
encode_protocol_type_set(&node_info.outbound_protocols, &mut ps_builder)?;
|
||||
|
||||
let mut ats_builder = builder.reborrow().init_address_types();
|
||||
encode_address_type_set(&node_info.address_types, &mut ats_builder)?;
|
||||
|
||||
builder.set_min_version(node_info.min_version);
|
||||
builder.set_max_version(node_info.max_version);
|
||||
@@ -47,13 +50,20 @@ pub fn decode_node_info(
|
||||
.map_err(RPCError::protocol)?,
|
||||
);
|
||||
|
||||
let outbound_protocols = decode_protocol_set(
|
||||
let outbound_protocols = decode_protocol_type_set(
|
||||
&reader
|
||||
.reborrow()
|
||||
.get_outbound_protocols()
|
||||
.map_err(RPCError::protocol)?,
|
||||
)?;
|
||||
|
||||
let address_types = decode_address_type_set(
|
||||
&reader
|
||||
.reborrow()
|
||||
.get_address_types()
|
||||
.map_err(RPCError::protocol)?,
|
||||
)?;
|
||||
|
||||
let min_version = reader.reborrow().get_min_version();
|
||||
let max_version = reader.reborrow().get_max_version();
|
||||
|
||||
@@ -90,6 +100,7 @@ pub fn decode_node_info(
|
||||
Ok(NodeInfo {
|
||||
network_class,
|
||||
outbound_protocols,
|
||||
address_types,
|
||||
min_version,
|
||||
max_version,
|
||||
dial_info_detail_list,
|
||||
|
@@ -1,33 +0,0 @@
|
||||
use crate::*;
|
||||
use rpc_processor::*;
|
||||
|
||||
pub fn encode_protocol_set(
|
||||
protocol_set: &ProtocolSet,
|
||||
builder: &mut veilid_capnp::protocol_set::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_udp(protocol_set.contains(ProtocolType::UDP));
|
||||
builder.set_tcp(protocol_set.contains(ProtocolType::TCP));
|
||||
builder.set_ws(protocol_set.contains(ProtocolType::WS));
|
||||
builder.set_wss(protocol_set.contains(ProtocolType::WSS));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn decode_protocol_set(
|
||||
reader: &veilid_capnp::protocol_set::Reader,
|
||||
) -> Result<ProtocolSet, RPCError> {
|
||||
let mut out = ProtocolSet::new();
|
||||
if reader.reborrow().get_udp() {
|
||||
out.insert(ProtocolType::UDP);
|
||||
}
|
||||
if reader.reborrow().get_tcp() {
|
||||
out.insert(ProtocolType::TCP);
|
||||
}
|
||||
if reader.reborrow().get_ws() {
|
||||
out.insert(ProtocolType::WS);
|
||||
}
|
||||
if reader.reborrow().get_wss() {
|
||||
out.insert(ProtocolType::WSS);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
33
veilid-core/src/rpc_processor/coders/protocol_type_set.rs
Normal file
33
veilid-core/src/rpc_processor/coders/protocol_type_set.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use crate::*;
|
||||
use rpc_processor::*;
|
||||
|
||||
pub fn encode_protocol_type_set(
|
||||
protocol_type_set: &ProtocolTypeSet,
|
||||
builder: &mut veilid_capnp::protocol_type_set::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_udp(protocol_type_set.contains(ProtocolType::UDP));
|
||||
builder.set_tcp(protocol_type_set.contains(ProtocolType::TCP));
|
||||
builder.set_ws(protocol_type_set.contains(ProtocolType::WS));
|
||||
builder.set_wss(protocol_type_set.contains(ProtocolType::WSS));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn decode_protocol_type_set(
|
||||
reader: &veilid_capnp::protocol_type_set::Reader,
|
||||
) -> Result<ProtocolTypeSet, RPCError> {
|
||||
let mut out = ProtocolTypeSet::new();
|
||||
if reader.reborrow().get_udp() {
|
||||
out.insert(ProtocolType::UDP);
|
||||
}
|
||||
if reader.reborrow().get_tcp() {
|
||||
out.insert(ProtocolType::TCP);
|
||||
}
|
||||
if reader.reborrow().get_ws() {
|
||||
out.insert(ProtocolType::WS);
|
||||
}
|
||||
if reader.reborrow().get_wss() {
|
||||
out.insert(ProtocolType::WSS);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
Reference in New Issue
Block a user