Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Oct 30, 2023
1 parent e87a907 commit a21ac9b
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 85 deletions.
10 changes: 5 additions & 5 deletions lib/xdrgen/generators/rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -679,7 +679,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1251,7 +1251,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1648,7 +1648,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2030,7 +2030,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
10 changes: 5 additions & 5 deletions spec/output/generator_spec_rust/block_comments.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -689,7 +689,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2040,7 +2040,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
10 changes: 5 additions & 5 deletions spec/output/generator_spec_rust/const.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -689,7 +689,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2040,7 +2040,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
10 changes: 5 additions & 5 deletions spec/output/generator_spec_rust/enum.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -689,7 +689,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2040,7 +2040,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
10 changes: 5 additions & 5 deletions spec/output/generator_spec_rust/nesting.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -689,7 +689,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2040,7 +2040,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
10 changes: 5 additions & 5 deletions spec/output/generator_spec_rust/optional.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -689,7 +689,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2040,7 +2040,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
10 changes: 5 additions & 5 deletions spec/output/generator_spec_rust/struct.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -689,7 +689,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2040,7 +2040,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
10 changes: 5 additions & 5 deletions spec/output/generator_spec_rust/test.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ fn pad_len(len: usize) -> usize {
/// required for each batch as it goes while reading so that no large
/// preallocation occurs without the message data being available.
#[cfg(feature = "std")]
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8> {
fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Result<Vec<u8>> {
let mut vec = vec![0u8; 0];
let mut len_remaining = len as usize;

Expand All @@ -689,7 +689,7 @@ fn read_exact_in_batches<R: Read>(r: R, len: usize, batch_size: usize) -> Vec<u8
r.read_exact(&mut vec[offset..])?;
len_remaining -= len_read;
}
vec
Ok(vec)
}

impl ReadXdr for i32 {
Expand Down Expand Up @@ -1261,7 +1261,7 @@ impl<const MAX: u32> ReadXdr for VecM<u8, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ impl<const MAX: u32> ReadXdr for BytesM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down Expand Up @@ -2040,7 +2040,7 @@ impl<const MAX: u32> ReadXdr for StringM<MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ);
let mut vec = read_exact_in_batches(r, len as usize, MAX_PREALLOCATED_BYTES_READ)?;

let pad = &mut [0u8; 3][..pad_len(len as usize)];
r.read_exact(pad)?;
Expand Down
Loading

0 comments on commit a21ac9b

Please sign in to comment.