Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract and generalize constant size policy #3272

Closed
tiziano88 opened this issue Oct 5, 2022 · 0 comments
Closed

Extract and generalize constant size policy #3272

tiziano88 opened this issue Oct 5, 2022 · 0 comments

Comments

@tiziano88
Copy link
Collaborator

Currently this logic is implemented as part of a Response message, which includes a status code

#[derive(Clone, PartialEq, Debug)]
pub struct Response {
pub status: StatusCode,
/// body (may include padding 0s)
pub body: alloc::vec::Vec<u8>,
/// The effective length of the body, excluding any padding contained
pub length: u64,
}

I think the logic should be extracted to just be about serializing an arbitrary byte array so that it has a constant size. Also the current implementation uses the same object to represent both a padded and unpadded response (since this is done by calling the pad method, not in the constructor). This seems error prone from a type safety point of view, since forgetting to pad the content would not be noticeable at the type level.

tiziano88 added a commit to tiziano88/oak that referenced this issue Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant