mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 01:12:56 +00:00
Use bounds() function
This commit is contained in:
@@ -169,12 +169,12 @@ impl<const BUFFERED: bool> BlobWriter<BUFFERED> {
|
||||
src_buf: Slice<Buf>,
|
||||
ctx: &RequestContext,
|
||||
) -> (Slice<Buf>, Result<(), Error>) {
|
||||
let begin_end = (src_buf.begin(), src_buf.end());
|
||||
let orig_bounds = src_buf.bounds();
|
||||
|
||||
macro_rules! return_ {
|
||||
macro_rules! return_orig_bounds {
|
||||
($buf:expr, $val:expr) => {{
|
||||
let buf = $buf.into_inner();
|
||||
return (buf.slice(begin_end.0..begin_end.1), $val);
|
||||
return (buf.slice(orig_bounds), $val);
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ impl<const BUFFERED: bool> BlobWriter<BUFFERED> {
|
||||
// Then, if the buffer is full, flush it out
|
||||
if self.buf.len() == Self::CAPACITY {
|
||||
if let Err(e) = self.flush_buffer(ctx).await {
|
||||
return_!(src_buf, Err(e));
|
||||
return_orig_bounds!(src_buf, Err(e));
|
||||
}
|
||||
}
|
||||
// Finally, write the tail of src_buf:
|
||||
@@ -213,14 +213,14 @@ impl<const BUFFERED: bool> BlobWriter<BUFFERED> {
|
||||
} else {
|
||||
let (src_buf, res) = self.write_all_unbuffered(src_buf, ctx).await;
|
||||
if let Err(e) = res {
|
||||
return_!(src_buf, Err(e));
|
||||
return_orig_bounds!(src_buf, Err(e));
|
||||
}
|
||||
src_buf
|
||||
}
|
||||
} else {
|
||||
src_buf
|
||||
};
|
||||
return_!(src_buf, Ok(()));
|
||||
return_orig_bounds!(src_buf, Ok(()));
|
||||
}
|
||||
|
||||
/// Write a blob of data. Returns the offset that it was written to,
|
||||
|
||||
@@ -680,12 +680,12 @@ impl VirtualFile {
|
||||
buf: Slice<Buf>,
|
||||
ctx: &RequestContext,
|
||||
) -> (Slice<Buf>, Result<usize, Error>) {
|
||||
let begin_end = (buf.begin(), buf.end());
|
||||
let begin_end = buf.bounds();
|
||||
|
||||
macro_rules! return_ {
|
||||
macro_rules! return_orig_bounds {
|
||||
($buf:expr, $val:expr) => {{
|
||||
let buf = $buf.into_inner();
|
||||
return (buf.slice(begin_end.0..begin_end.1), $val);
|
||||
return (buf.slice(begin_end), $val);
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ impl VirtualFile {
|
||||
(buf, res) = self.write(buf, ctx).await;
|
||||
match res {
|
||||
Ok(0) => {
|
||||
return_!(
|
||||
return_orig_bounds!(
|
||||
buf,
|
||||
Err(Error::new(
|
||||
std::io::ErrorKind::WriteZero,
|
||||
@@ -711,11 +711,11 @@ impl VirtualFile {
|
||||
buf = buf.slice(n..);
|
||||
}
|
||||
Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => {}
|
||||
Err(e) => return_!(buf, Err(e)),
|
||||
Err(e) => return_orig_bounds!(buf, Err(e)),
|
||||
}
|
||||
}
|
||||
|
||||
return_!(buf, Ok(nbytes));
|
||||
return_orig_bounds!(buf, Ok(nbytes));
|
||||
}
|
||||
|
||||
async fn write<B: IoBuf + Send>(
|
||||
|
||||
Reference in New Issue
Block a user