refactor checkpoint

This commit is contained in:
John Smith
2022-04-20 20:49:16 -04:00
parent 0440391189
commit 5b0ade9f49
6 changed files with 168 additions and 132 deletions

View File

@@ -5,10 +5,10 @@ pub fn encode_protocol_set(
protocol_set: &ProtocolSet,
builder: &mut veilid_capnp::protocol_set::Builder,
) -> Result<(), RPCError> {
builder.set_udp(protocol_set.udp);
builder.set_tcp(protocol_set.tcp);
builder.set_ws(protocol_set.ws);
builder.set_wss(protocol_set.wss);
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(())
}
@@ -16,10 +16,18 @@ pub fn encode_protocol_set(
pub fn decode_protocol_set(
reader: &veilid_capnp::protocol_set::Reader,
) -> Result<ProtocolSet, RPCError> {
Ok(ProtocolSet {
udp: reader.reborrow().get_udp(),
tcp: reader.reborrow().get_tcp(),
ws: reader.reborrow().get_ws(),
wss: reader.reborrow().get_wss(),
})
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)
}