Skip to content

Commit

Permalink
Move reply_size to member function
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Jun 29, 2023
1 parent 4f91421 commit 3817af2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
10 changes: 1 addition & 9 deletions cmd/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,7 @@ impl<'a> RpcClient<'a> {

let our_image_id = self.hubris.image_id().unwrap();

let nreply = match op.operation.encoding {
::idol::syntax::Encoding::Zerocopy => {
self.hubris.typesize(op.ok)?
}
::idol::syntax::Encoding::Ssmarshal
| ::idol::syntax::Encoding::Hubpack => {
self.hubris.hubpack_serialized_maxsize(op.ok)?
}
};
let nreply = op.reply_size()?;

let header = RpcHeader {
image_id: U64::from_bytes(our_image_id.try_into().unwrap()),
Expand Down
16 changes: 1 addition & 15 deletions humility-hiffy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,21 +778,7 @@ impl<'a> HiffyContext<'a> {
}

ops.push(push(payload.len() as u32));
let reply_size = match op.operation.encoding {
::idol::syntax::Encoding::Zerocopy => {
self.hubris.typesize(op.ok)?
}
::idol::syntax::Encoding::Ssmarshal
| ::idol::syntax::Encoding::Hubpack => {
let ok = self.hubris.hubpack_serialized_maxsize(op.ok)?;
if let idol::IdolError::Complex(e) = op.error {
ok.max(self.hubris.hubpack_serialized_maxsize(e.goff)?)
} else {
ok
}
}
};
ops.push(push(reply_size as u32));
ops.push(push(op.reply_size()? as u32));
if let Some(lease_size) = lease_size {
ops.push(push(lease_size));
}
Expand Down
18 changes: 18 additions & 0 deletions humility-idol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,24 @@ impl<'a> IdolOperation<'a> {
format!("<Unknown {}.{} error: {}>", self.name.0, self.name.1, code)
}
}

pub fn reply_size(&self) -> Result<usize> {
let reply_size = match self.operation.encoding {
::idol::syntax::Encoding::Zerocopy => {
self.hubris.typesize(self.ok)?
}
::idol::syntax::Encoding::Ssmarshal
| ::idol::syntax::Encoding::Hubpack => {
let ok = self.hubris.hubpack_serialized_maxsize(self.ok)?;
if let IdolError::Complex(e) = self.error {
ok.max(self.hubris.hubpack_serialized_maxsize(e.goff)?)
} else {
ok
}
}
};
Ok(reply_size)
}
}

//
Expand Down

0 comments on commit 3817af2

Please sign in to comment.