alignment refactor

This commit is contained in:
John Smith
2022-12-16 21:55:03 -05:00
parent 221c09b555
commit 16d74b96f3
23 changed files with 138 additions and 108 deletions

View File

@@ -444,7 +444,11 @@ impl ClientApiConnection {
res.map_err(map_to_string)
}
pub async fn server_appcall_reply(&mut self, id: u64, msg: Vec<u8>) -> Result<(), String> {
pub async fn server_appcall_reply(
&mut self,
id: OperationId,
msg: Vec<u8>,
) -> Result<(), String> {
trace!("ClientApiConnection::appcall_reply");
let server = {
let inner = self.inner.borrow();
@@ -455,7 +459,7 @@ impl ClientApiConnection {
.clone()
};
let mut request = server.borrow().app_call_reply_request();
request.get().set_id(id);
request.get().set_id(id.as_u64());
request.get().set_message(&msg);
let response = self
.cancellable(request.send().promise)

View File

@@ -47,7 +47,7 @@ struct CommandProcessorInner {
autoreconnect: bool,
server_addr: Option<SocketAddr>,
connection_waker: Eventual,
last_call_id: Option<u64>,
last_call_id: Option<OperationId>,
}
type Handle<T> = Rc<RefCell<T>>;
@@ -249,7 +249,7 @@ reply - reply to an AppCall not handled directly by the server
}
Ok(v) => v,
};
(id, second)
(OperationId::new(id), second)
} else {
let id = match some_last_id {
None => {
@@ -394,8 +394,8 @@ reply - reply to an AppCall not handled directly by the server
pub fn update_network_status(&mut self, network: veilid_core::VeilidStateNetwork) {
self.inner_mut().ui.set_network_status(
network.started,
network.bps_down,
network.bps_up,
network.bps_down.as_u64(),
network.bps_up.as_u64(),
network.peers,
);
}
@@ -471,7 +471,9 @@ reply - reply to an AppCall not handled directly by the server
self.inner().ui.add_node_event(format!(
"AppCall ({:?}) id = {:016x} : {}",
call.sender, call.id, strmsg
call.sender,
call.id.as_u64(),
strmsg
));
self.inner_mut().last_call_id = Some(call.id);

View File

@@ -1,7 +1,7 @@
use super::*;
use cursive_table_view::*;
use std::cmp::Ordering;
use veilid_core::PeerTableData;
use veilid_core::*;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum PeerTableColumn {
@@ -24,7 +24,8 @@ pub enum PeerTableColumn {
// }
// }
fn format_ts(ts: u64) -> String {
fn format_ts(ts: Timestamp) -> String {
let ts = ts.as_u64();
let secs = timestamp_to_secs(ts);
if secs >= 1.0 {
format!("{:.2}s", timestamp_to_secs(ts))
@@ -33,7 +34,8 @@ fn format_ts(ts: u64) -> String {
}
}
fn format_bps(bps: u64) -> String {
fn format_bps(bps: ByteCount) -> String {
let bps = bps.as_u64();
if bps >= 1024u64 * 1024u64 * 1024u64 {
format!("{:.2}GB/s", (bps / (1024u64 * 1024u64)) as f64 / 1024.0)
} else if bps >= 1024u64 * 1024u64 {