aboutsummaryrefslogtreecommitdiff
path: root/src/buf/buf_impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/buf/buf_impl.rs')
-rw-r--r--src/buf/buf_impl.rs48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/buf/buf_impl.rs b/src/buf/buf_impl.rs
index 3c596f1..16ad8a7 100644
--- a/src/buf/buf_impl.rs
+++ b/src/buf/buf_impl.rs
@@ -16,7 +16,7 @@ macro_rules! buf_get_impl {
// this Option<ret> trick is to avoid keeping a borrow on self
// when advance() is called (mut borrow) and to call bytes() only once
let ret = $this
- .bytes()
+ .chunk()
.get(..SIZE)
.map(|src| unsafe { $typ::$conv(*(src as *const _ as *const [_; SIZE])) });
@@ -78,7 +78,7 @@ pub trait Buf {
/// the buffer.
///
/// This value is greater than or equal to the length of the slice returned
- /// by `bytes`.
+ /// by `chunk()`.
///
/// # Examples
///
@@ -115,31 +115,31 @@ pub trait Buf {
///
/// let mut buf = &b"hello world"[..];
///
- /// assert_eq!(buf.bytes(), &b"hello world"[..]);
+ /// assert_eq!(buf.chunk(), &b"hello world"[..]);
///
/// buf.advance(6);
///
- /// assert_eq!(buf.bytes(), &b"world"[..]);
+ /// assert_eq!(buf.chunk(), &b"world"[..]);
/// ```
///
/// # Implementer notes
///
/// This function should never panic. Once the end of the buffer is reached,
- /// i.e., `Buf::remaining` returns 0, calls to `bytes` should return an
+ /// i.e., `Buf::remaining` returns 0, calls to `chunk()` should return an
/// empty slice.
- fn bytes(&self) -> &[u8];
+ fn chunk(&self) -> &[u8];
/// Fills `dst` with potentially multiple slices starting at `self`'s
/// current position.
///
- /// If the `Buf` is backed by disjoint slices of bytes, `bytes_vectored` enables
+ /// If the `Buf` is backed by disjoint slices of bytes, `chunk_vectored` enables
/// fetching more than one slice at once. `dst` is a slice of `IoSlice`
/// references, enabling the slice to be directly used with [`writev`]
/// without any further conversion. The sum of the lengths of all the
/// buffers in `dst` will be less than or equal to `Buf::remaining()`.
///
/// The entries in `dst` will be overwritten, but the data **contained** by
- /// the slices **will not** be modified. If `bytes_vectored` does not fill every
+ /// the slices **will not** be modified. If `chunk_vectored` does not fill every
/// entry in `dst`, then `dst` is guaranteed to contain all remaining slices
/// in `self.
///
@@ -149,7 +149,7 @@ pub trait Buf {
/// # Implementer notes
///
/// This function should never panic. Once the end of the buffer is reached,
- /// i.e., `Buf::remaining` returns 0, calls to `bytes_vectored` must return 0
+ /// i.e., `Buf::remaining` returns 0, calls to `chunk_vectored` must return 0
/// without mutating `dst`.
///
/// Implementations should also take care to properly handle being called
@@ -157,13 +157,13 @@ pub trait Buf {
///
/// [`writev`]: http://man7.org/linux/man-pages/man2/readv.2.html
#[cfg(feature = "std")]
- fn bytes_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize {
+ fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize {
if dst.is_empty() {
return 0;
}
if self.has_remaining() {
- dst[0] = IoSlice::new(self.bytes());
+ dst[0] = IoSlice::new(self.chunk());
1
} else {
0
@@ -172,7 +172,7 @@ pub trait Buf {
/// Advance the internal cursor of the Buf
///
- /// The next call to `bytes` will return a slice starting `cnt` bytes
+ /// The next call to `chunk()` will return a slice starting `cnt` bytes
/// further into the underlying buffer.
///
/// # Examples
@@ -182,11 +182,11 @@ pub trait Buf {
///
/// let mut buf = &b"hello world"[..];
///
- /// assert_eq!(buf.bytes(), &b"hello world"[..]);
+ /// assert_eq!(buf.chunk(), &b"hello world"[..]);
///
/// buf.advance(6);
///
- /// assert_eq!(buf.bytes(), &b"world"[..]);
+ /// assert_eq!(buf.chunk(), &b"world"[..]);
/// ```
///
/// # Panics
@@ -253,7 +253,7 @@ pub trait Buf {
let cnt;
unsafe {
- let src = self.bytes();
+ let src = self.chunk();
cnt = cmp::min(src.len(), dst.len() - off);
ptr::copy_nonoverlapping(src.as_ptr(), dst[off..].as_mut_ptr(), cnt);
@@ -283,7 +283,7 @@ pub trait Buf {
/// This function panics if there is no more remaining data in `self`.
fn get_u8(&mut self) -> u8 {
assert!(self.remaining() >= 1);
- let ret = self.bytes()[0];
+ let ret = self.chunk()[0];
self.advance(1);
ret
}
@@ -306,7 +306,7 @@ pub trait Buf {
/// This function panics if there is no more remaining data in `self`.
fn get_i8(&mut self) -> i8 {
assert!(self.remaining() >= 1);
- let ret = self.bytes()[0] as i8;
+ let ret = self.chunk()[0] as i8;
self.advance(1);
ret
}
@@ -861,7 +861,7 @@ pub trait Buf {
/// let mut chain = b"hello "[..].chain(&b"world"[..]);
///
/// let full = chain.copy_to_bytes(11);
- /// assert_eq!(full.bytes(), b"hello world");
+ /// assert_eq!(full.chunk(), b"hello world");
/// ```
fn chain<U: Buf>(self, next: U) -> Chain<Self, U>
where
@@ -908,13 +908,13 @@ macro_rules! deref_forward_buf {
(**self).remaining()
}
- fn bytes(&self) -> &[u8] {
- (**self).bytes()
+ fn chunk(&self) -> &[u8] {
+ (**self).chunk()
}
#[cfg(feature = "std")]
- fn bytes_vectored<'b>(&'b self, dst: &mut [IoSlice<'b>]) -> usize {
- (**self).bytes_vectored(dst)
+ fn chunks_vectored<'b>(&'b self, dst: &mut [IoSlice<'b>]) -> usize {
+ (**self).chunks_vectored(dst)
}
fn advance(&mut self, cnt: usize) {
@@ -1022,7 +1022,7 @@ impl Buf for &[u8] {
}
#[inline]
- fn bytes(&self) -> &[u8] {
+ fn chunk(&self) -> &[u8] {
self
}
@@ -1045,7 +1045,7 @@ impl<T: AsRef<[u8]>> Buf for std::io::Cursor<T> {
len - pos as usize
}
- fn bytes(&self) -> &[u8] {
+ fn chunk(&self) -> &[u8] {
let len = self.get_ref().as_ref().len();
let pos = self.position();
ss='logsubject'>experiment: use bmalloc/libpas instead of mimalloc in most placesGravatar Jarred Sumner 13-82/+165 2023-07-29typo spawn.md (#3875)Gravatar Jhorman Tito 1-1/+1 2023-07-28Update nodejs-apis.mdGravatar Jarred Sumner 1-4/+4 2023-07-28Update nodejs-apis.mdGravatar Jarred Sumner 1-5/+5 2023-07-28Defer task destructionbun-v0.7.1Gravatar Jarred Sumner 1-1/+17 2023-07-28Stat largefile test (#3870)Gravatar Jarred Sumner 1-0/+22 * Add test for stat on a large file * Update fs.test.ts --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-28Ignore when printing to stdout errors (#3869)Gravatar Jarred Sumner 1-2/+4 Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-28Fix bug with `/path/to/absolute/bun.lockb`Gravatar Jarred Sumner 1-10/+13 2023-07-28markBindingGravatar Dylan Conway 1-0/+1 2023-07-28optional parameterGravatar Dylan Conway 1-3/+3 2023-07-28Fixes #3868Gravatar Jarred Sumner 1-2/+3 Fixes #3868 Fixes #849 2023-07-28Fix assertion failure and possible infinite loop when printing as yarn lock ↵Gravatar Jarred Sumner 2-3/+16 files 2023-07-28Mark broken test as todoGravatar Jarred Sumner 2-1/+5 2023-07-28fix types and add message channel/port gc testGravatar Dylan Conway 2-62/+18 2023-07-28`MessageChannel` and `MessagePort` (#3860)Gravatar Dylan Conway 57-247/+3752 * copy and format * copy * copy * cleanup * some tests * spellcheck * add types * don't lock getting contextId * array buffer test 2023-07-28mark tests as todoGravatar Jarred Sumner 2-81/+75 2023-07-28add fork to child_process (#3851)Gravatar Vlad Sirenko 7-19/+446 * add fork to child_process * fix export * add test to child_process method `fork` * fmt fork * remove only from test 2023-07-28feat(bun/test): Impl. expect().pass() & expect().fail() (#3843)Gravatar Tiramify (A.K. Daniel) 6-5/+212 * Impl. pass & fail * fix * fix 2 * smol 2023-07-28fix the chunk boundary (`node:stream:createReadStream`) (#3853)Gravatar Ai Hoshino 3-8/+90 * fix the slice boundary. Close: #3668 * Add more boundary test case. * fix end is 0. 2023-07-28Support file: URLs in `fetch` (#3858)Gravatar Jarred Sumner 6-183/+281 * Support file: URLs in `fetch` * Update url.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-28fix(tls) exposes native canonicalizeIP and fix rootCertificates (#3866)Gravatar Ciro Spaciari 7-29/+125 * exposes native canonicalizeIP * remove unintended duplicate * add tests * add tests for debug builds * add rootCertificates test and fix len * just randomize test ids on prisma * remove work around and bump usockets with the actual fix * fix case * bump uws 2023-07-28Fixes #3795 (#3856)Gravatar Jarred Sumner 11-6/+140 Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-28Add todoGravatar Jarred Sumner 2-0/+8 cc @cirospaciari 2023-07-28Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-28Update pull_request_template.mdGravatar Jarred Sumner 1-11/+16 2023-07-27Fix bug with // @bun annotation in main thread (#3855)Gravatar Jarred Sumner 4-2/+53 * Uncomment test * Fix bug with // @bun + async transpiler --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-27Add `Bun.isMainThread`Gravatar Jarred Sumner 7-3/+48 2023-07-27Uncomment testGravatar Jarred Sumner 1-1/+1 2023-07-27Resolve watch directories outside main thread + async iterator and symlink ↵Gravatar Ciro Spaciari 8-197/+523 fixes (#3846) * linux working pending tests with FSEvents * add more tests, fix async iterator * remove unnecessary check * fix macos symlink on directories * remove indirection layer * todos * fixes and some permission test * fix opsie and make prisma test more reliable * rebase with main * add comptime check for macOS * oops * oops2 * fix symlinks cascade on FSEvents * use JSC.WorkPool * use withResolver, createFIFO and fix close event on async iterator * remove unused events --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-1/+1 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-2/+2 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-0/+4 2023-07-27Update pull_request_template.mdGravatar Jarred Sumner 1-5/+11