From e8989c82ae1f9fca01e27a44daefa2d70ac6046e Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 6 Nov 2026 23:17:59 -0800 Subject: [PATCH 1/3] chore(quest): claim quest/m3/ts-bufmut-slices.md Quest-Claim: 7ed00e0424c1a603 From 67911bb8e4b12612a00ca1987870b9b763f936c8 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Sat, 7 Nov 2026 00:25:12 -0800 Subject: [PATCH 2/3] feat(ts): translate bytes' BufMut for a &mut [u8] and a &mut [MaybeUninit] A `&mut [u8]` counted as a mapped buffer, though no mapping writes one, so every call into its impl refused. It now translates from the MIR, as the `MaybeUninit` impl already did, and `ptr::write_bytes` of bytes maps, which the provided `put_bytes` reaches through the forwarding impls. Its other pointees are refused, and a write the body shows past an array JS keeps apart is too. A differential case writes an array through each slice, directly, through a `&mut`, and through a `Box`. Co-Authored-By: Claude Opus 5.5 --- quest/m3/README.md | 1 - quest/m3/ts-bufmut-slices.md | 19 - ts/README.md | 12 +- ts/fixtures/reject/census.txt | 2 + ts/fixtures/reject/expected.txt | 2 + ts/fixtures/reject/src/pointers.rs | 10 + ts/fixtures/reject/ts.toml | 1 + ts/fixtures/stock/expected/buf.ts | 592 +- .../stock/expected/bytes/buf/buf_mut.ts | 5608 ++++++++++++++--- ts/fixtures/stock/expected/harness.ts | 6 +- ts/fixtures/stock/src/buf.rs | 64 +- ts/fixtures/stock/src/harness.rs | 1 + ts/runtime/rs.ts | 8 + ts/src/lower/mir/origin.rs | 1 + ts/src/lower/pointer.rs | 18 + ts/src/lower/stock.rs | 9 +- 16 files changed, 5542 insertions(+), 812 deletions(-) delete mode 100644 quest/m3/ts-bufmut-slices.md diff --git a/quest/m3/README.md b/quest/m3/README.md index 73adb9533..438f8a8c8 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -24,5 +24,4 @@ generic std gap is planned here even when moq never calls it. - [rust2-ts with no ts.toml](/quest/m3/ts-configless.md) - a crate's whole `pub` API translates with no config and no bound items - [std's panic messages hold std's capacity](/quest/m3/ts-panic-payload-capacity.md) - a hook reads native's `String` capacity from std's own formatted panics - [Browser APIs through wasm-bindgen](/quest/m3/ts-wasm-bindgen/README.md) - web-sys and js-sys imports become direct JS calls, so idiomatic crates such as web-rs's web-codecs translate as stock crates -- [BufMut on a byte slice](/quest/m3/ts-bufmut-slices.md) - `bytes`' `BufMut` for `&mut [u8]` and `&mut [MaybeUninit]` translates - [Fields typed by an associated type](/quest/m3/ts-assoc-type-fields.md) - a generic struct's field of `::Item` translates at each instance diff --git a/quest/m3/ts-bufmut-slices.md b/quest/m3/ts-bufmut-slices.md deleted file mode 100644 index a882455f2..000000000 --- a/quest/m3/ts-bufmut-slices.md +++ /dev/null @@ -1,19 +0,0 @@ -# [S] BufMut on a byte slice - -## Goal - -[rust2-ts](/ts/README.md) translates `bytes`' `impl BufMut for &mut [u8]` and -`impl BufMut for &mut [MaybeUninit]`, which write at the slice's front and advance -past what they wrote, proven by differential tests against native Rust. - -## Plan - -Suggested on [#611](https://github.com/moq-dev/rust2/pull/611), which mapped `Buf` for a -`VecDeque`: `mapped_self` (`ts/src/lower/stock.rs`) counts any `&[u8]` or `&mut [u8]` -as mapped, but no `Buffer` covers a mutable slice, so both impls look refused the way the -deque was. That was read from the code, not a test; reproduce it first. - -Decided with the maintainer on 2026-11-07: ✅ m3 (rejected: m2, drop), since rust2 aims to -support all of std and its common crates' impls. No consumer at the moq pin. - -Public API: the translator's output. diff --git a/ts/README.md b/ts/README.md index a64f2f0b1..246bc4ce4 100644 --- a/ts/README.md +++ b/ts/README.md @@ -110,7 +110,7 @@ crate translation reaches is refused, and so are two versions of one crate it re | `Vec` | `rs.Vec`: its items, the array `items`, and the capacity std's holds; `rs.vecFrom(items)` makes one of an array with room for exactly them. `rs.ByteVec` of bytes | | `Cow<[T]>`, `Cow` | `rs.Cow`: the `Vec` it owns, or an `rs.Borrowed` holding the slice it borrows; `rs.ByteCow` for bytes, an `rs.ByteVec` or an `rs.ByteSlice`; `rs.StrCow` for text, the `rs.String` it owns or an `rs.Borrowed` holding the string it borrows, whose text `rs.strCowStr` reads | | `&T`, `&mut T`, `Box`, `Reverse`, `NonZero`, `AssertUnwindSafe` | the value; a `&mut` to a value JS copies, such as a number, an `Option`, or a reference, or to an `Arc`, a `Waker`, or a `LocalKey`, whose copies share what it points at, is an `rs.Place`, which for what a box holds is the place holding the box | -| `*const T`, `*mut T`, `NonNull` | what a `&mut T` is: the object, an `rs.Slice` of a `[T; N]`'s elements or an `rs.ByteSlice` of a `[u8; N]`'s bytes, which compares by the array or buffer and offset they are at, refused for an array of one, which `array::from_ref`, `from_mut` of a variable, and `Option::as_slice` make of their own, or an `rs.Place` to a value JS copies and to a library type such as a `Vec` or an `Arc`, which into an array, slice, or `Vec` is the `rs.AtIndex` of its element, which `add`, `sub`, `offset`, their wrapping forms, `offset_from`, `ptr::copy`, and `slice::from_raw_parts` move, measure, copy between, and view; one to a value in no array is element 0 of an array of one, as in Rust; JS keeps that array, and a shared subslice, which JS copies, apart from what holds it in Rust, so a pointer, slice, or copy the body shows reaching past either, a raw or mutable slice of a byte in no array, and `offset_from` between pointers the body shows JS keeps in different arrays are refused, and through a pointer from elsewhere, such as a field, any of these, or a read or write past the array JS keeps it in but for a `Vec`'s room up to its capacity, fails at run time; a pointer into an array of values JS keeps as objects is refused, as is comparing pointers to other values JS copies, each a place JS makes of its own; `rs.NULL` for null and `rs.DANGLING` for dangling. A pointer to a slice cast to one to an array of its elements is the `rs.Slice` or `rs.ByteSlice` of that many from its first, read through only where Rust reads. A `*const ()` is an identity, such as a waker's data, and `rs.DANGLING_UNIT` when dangling; one to a place of `()` or from a reference to one is refused. A pointer to a value JS keeps as an object cast to one, by `as` or `cast`, is the same object, which `rs.ptrErase` notes the type of, so a cast back to a pointer to another type fails at run time, and null and dangling stay so, dangling at the alignment of the type it was cast from; one to a value JS copies is the same place where an `Arc`'s or `Rc`'s `into_raw` or `as_ptr` gave it, its value's one place, which `rs.arcErase` checks where the body doesn't show it, and refused where the body shows a borrow's, a new place each borrow, as is casting one to a view of bytes, a new one each borrow, or one of no fixed size. A write of a whole object copies into it one object deep, as an assignment through a `&mut` does, the state an `rs` class such as `rs.LazyCell` keeps private included, so a pointer to a part kept as an object, such as a field of a tuple or struct type, is refused wherever the crate may put another object there while a pointer into that memory may still be read, which a write into a fresh allocation, or a variable before any pointer into it is taken, can't, whether by index or through std's iterators over its slots; a read copies what the crate writes into in place | +| `*const T`, `*mut T`, `NonNull` | what a `&mut T` is: the object, an `rs.Slice` of a `[T; N]`'s elements or an `rs.ByteSlice` of a `[u8; N]`'s bytes, which compares by the array or buffer and offset they are at, refused for an array of one, which `array::from_ref`, `from_mut` of a variable, and `Option::as_slice` make of their own, or an `rs.Place` to a value JS copies and to a library type such as a `Vec` or an `Arc`, which into an array, slice, or `Vec` is the `rs.AtIndex` of its element, which `add`, `sub`, `offset`, their wrapping forms, `offset_from`, `ptr::copy`, `write_bytes` of bytes, and `slice::from_raw_parts` move, measure, copy between, set, and view; one to a value in no array is element 0 of an array of one, as in Rust; JS keeps that array, and a shared subslice, which JS copies, apart from what holds it in Rust, so a pointer, slice, copy, or write of bytes the body shows reaching past either, a raw or mutable slice of a byte in no array, and `offset_from` between pointers the body shows JS keeps in different arrays are refused, and through a pointer from elsewhere, such as a field, any of these, or a read or write past the array JS keeps it in but for a `Vec`'s room up to its capacity, fails at run time; a pointer into an array of values JS keeps as objects is refused, as is comparing pointers to other values JS copies, each a place JS makes of its own; `rs.NULL` for null and `rs.DANGLING` for dangling. A pointer to a slice cast to one to an array of its elements is the `rs.Slice` or `rs.ByteSlice` of that many from its first, read through only where Rust reads. A `*const ()` is an identity, such as a waker's data, and `rs.DANGLING_UNIT` when dangling; one to a place of `()` or from a reference to one is refused. A pointer to a value JS keeps as an object cast to one, by `as` or `cast`, is the same object, which `rs.ptrErase` notes the type of, so a cast back to a pointer to another type fails at run time, and null and dangling stay so, dangling at the alignment of the type it was cast from; one to a value JS copies is the same place where an `Arc`'s or `Rc`'s `into_raw` or `as_ptr` gave it, its value's one place, which `rs.arcErase` checks where the body doesn't show it, and refused where the body shows a borrow's, a new place each borrow, as is casting one to a view of bytes, a new one each borrow, or one of no fixed size. A write of a whole object copies into it one object deep, as an assignment through a `&mut` does, the state an `rs` class such as `rs.LazyCell` keeps private included, so a pointer to a part kept as an object, such as a field of a tuple or struct type, is refused wherever the crate may put another object there while a pointer into that memory may still be read, which a write into a fresh allocation, or a variable before any pointer into it is taken, can't, whether by index or through std's iterators over its slots; a read copies what the crate writes into in place | | `MaybeUninit` | `T`: `undefined` until written, `0` for a byte, or an object whose parts kept as objects are there, holding `undefined`, as each of `Box::new_uninit_slice`'s is; a slice's `write_clone_of_slice` clones into its slots without dropping what they held | | `ManuallyDrop` | `T`, which nothing drops but its own `drop`; its `Debug`, comparisons, and constants are refused | | `union` | an object of slots named by offset, `at0` and `at8`, each holding the field part kept there; fields must overlap in the same type, or in a non-null pointer and an `Option` of it | @@ -770,9 +770,10 @@ of them: which grow it as their provided bodies do, 64 bytes at a time once it is full. `put` of the crate's own `Buf` through them into a `BytesMut` is refused, as `bytes` advances it by the room left in the capacity. - The rest of `bytes`, such as the other provided methods of the crate's own `Buf` and - its `Buf` of a `VecDeque`, whose `chunk` is the deque's front slice, translates - from its MIR, refused where that is. + The rest of `bytes`, such as the other provided methods of the crate's own `Buf`, its + `Buf` of a `VecDeque`, whose `chunk` is the deque's front slice, and its `BufMut` + of a `&mut [u8]` and a `&mut [MaybeUninit]`, which write the slice's front and + move it past what they wrote, translates from its MIR, refused where that is. - `hashbrown`'s `HashMap` and `HashSet` are std's, which wrap them, and map as std's do, hashbrown's own methods included: `allocation_size` is a slot and a control byte for each entry the capacity holds, and its `Entry` is std's. Its `HashTable` keeps each item @@ -1213,7 +1214,8 @@ so adding, removing, or reordering a case changes no other case's inputs. piece's bytes and capacity, after the other handles of its storage dropped or not, and reads and writes through `Buf` and `BufMut` generically, through a `&mut` and a `Box` too, a buffer of its own and a `VecDeque` wrapped at each slot included, ending with - each vector's capacity. It copies bytes out of `Chain`s of each kind of buffer, nested and as + each vector's capacity, and writes an array through a `&mut [u8]` and a + `&mut [MaybeUninit]` of each room, ending with the room left and the array. It copies bytes out of `Chain`s of each kind of buffer, nested and as `dyn Buf`s, at either end of each half and past the end. It changes hashbrown's maps and sets, keyed by JS primitives and by tuples, and `HashTable`s of tuples and of numbers, whose places it writes, under hashes that collide and that pass 2^53, checks their capacity by std's guarantees, and writes a diff --git a/ts/fixtures/reject/census.txt b/ts/fixtures/reject/census.txt index 15daa35e1..4d791e2cb 100644 --- a/ts/fixtures/reject/census.txt +++ b/ts/fixtures/reject/census.txt @@ -236,6 +236,8 @@ fixtures/reject/src/pointers.rs:variable_cloned_into+2:10: a raw pointer to `(u3 fixtures/reject/src/pointers.rs:variable_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there fixtures/reject/src/pointers.rs:variable_replaced+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there fixtures/reject/src/pointers.rs:variable_swapped+3:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:written_bytes+2:3: `write_bytes` of a pointer to `u32`, whose bytes JS keeps as a value +fixtures/reject/src/pointers.rs:written_bytes+3:16: a write reaching past a value in no array, which JS keeps apart from what holds it in Rust fixtures/reject/src/rebound.rs:bytes_compared_rebound+2:19: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there fixtures/reject/src/rebound.rs:cell_rebound+2:18: a reference to `std::cell::UnsafeCell`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there fixtures/reject/src/rebound.rs:chosen_compared_rebound+3:17: a reference to `rebound::Chosen`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there diff --git a/ts/fixtures/reject/expected.txt b/ts/fixtures/reject/expected.txt index af035c139..502204dee 100644 --- a/ts/fixtures/reject/expected.txt +++ b/ts/fixtures/reject/expected.txt @@ -238,6 +238,8 @@ fixtures/reject/src/pointers.rs:variable_cloned_into+2:10: a raw pointer to `(u3 fixtures/reject/src/pointers.rs:variable_reassigned+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there fixtures/reject/src/pointers.rs:variable_replaced+2:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there fixtures/reject/src/pointers.rs:variable_swapped+3:10: a raw pointer to `(u32, u32)` in a variable assigned again while it may point there +fixtures/reject/src/pointers.rs:written_bytes+2:3: `write_bytes` of a pointer to `u32`, whose bytes JS keeps as a value +fixtures/reject/src/pointers.rs:written_bytes+3:16: a write reaching past a value in no array, which JS keeps apart from what holds it in Rust fixtures/reject/src/rebound.rs:bytes_compared_rebound+2:19: a reference to `[u8; 4]`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there fixtures/reject/src/rebound.rs:cell_rebound+2:18: a reference to `std::cell::UnsafeCell`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there fixtures/reject/src/rebound.rs:chosen_compared_rebound+3:17: a reference to `rebound::Chosen`, through which a raw pointer may be made, in a variable assigned again while that pointer may point there diff --git a/ts/fixtures/reject/src/pointers.rs b/ts/fixtures/reject/src/pointers.rs index 0f5a155c3..b7d21a6a0 100644 --- a/ts/fixtures/reject/src/pointers.rs +++ b/ts/fixtures/reject/src/pointers.rs @@ -445,6 +445,16 @@ pub fn reached_out(h: Halves, lanes: [u32; 4]) -> u32 { } } +/// `write_bytes` through a pointer to what JS keeps as a value rather than its bytes, and +/// through one to a byte in no array, past it. +pub fn written_bytes(mut lanes: [u32; 2], mut b: u8) -> u32 { + unsafe { + std::ptr::write_bytes(lanes.as_mut_ptr(), 0, 2); + (&raw mut b).write_bytes(0xff, 2); + } + lanes[0] + u32::from(b) +} + /// A slice of one `u8`'s place, which no `rs.ByteSlice` views. pub fn byte_slice_of_place(b: &mut u8) { std::slice::from_mut(b)[0] = 1; diff --git a/ts/fixtures/reject/ts.toml b/ts/fixtures/reject/ts.toml index 4d5efb53d..c345424cd 100644 --- a/ts/fixtures/reject/ts.toml +++ b/ts/fixtures/reject/ts.toml @@ -171,6 +171,7 @@ roots = [ "pointers::variable_reassigned", "pointers::variable_replaced", "pointers::variable_swapped", + "pointers::written_bytes", "rebound::bytes_compared_rebound", "rebound::cell_rebound", "rebound::chosen_compared_rebound", diff --git a/ts/fixtures/stock/expected/buf.ts b/ts/fixtures/stock/expected/buf.ts index 74747c0bd..82ad00603 100644 --- a/ts/fixtures/stock/expected/buf.ts +++ b/ts/fixtures/stock/expected/buf.ts @@ -12,7 +12,7 @@ import * as Spare from "./buf.Spare.ts"; import * as Tagged from "./buf.Tagged.ts"; import { chunksVectored$bytes_Buf_bytes_Bytes as buf_impl_chunksVectored$bytes_Buf_bytes_Bytes, chunksVectored$bytes_Buf_bytes_BytesMut as buf_impl_chunksVectored$bytes_Buf_bytes_BytesMut, chunksVectored$bytes_Buf_ref_slice_u8 as buf_impl_chunksVectored$bytes_Buf_ref_slice_u8, copyToSlice$bytes_Buf_collections_VecDeque_u8, getU8$bytes_Buf_collections_VecDeque_u8, getI8$bytes_Buf_collections_VecDeque_u8, getUint$bytes_Buf_collections_VecDeque_u8, getIntLe$bytes_Buf_collections_VecDeque_u8, getF32Le$bytes_Buf_collections_VecDeque_u8, getF64$bytes_Buf_collections_VecDeque_u8, tryGetU8$bytes_Buf_bytes_Bytes, tryGetU8$bytes_Buf_bytes_BytesMut, tryGetU8$bytes_Buf_collections_VecDeque_u8, tryGetU8$bytes_Buf_ref_slice_u8, take$bytes_Buf_bytes_Bytes as buf_impl_take$bytes_Buf_bytes_Bytes, take$bytes_Buf_ref_slice_u8 as buf_impl_take$bytes_Buf_ref_slice_u8, chain$bytes_Buf_boxed_Box_dyn_bytes_Buf_bytes_Bytes, chain$bytes_Buf_bytes_Bytes_bytes_buf_Chain_buf_Provided_ref_slice_u8, chain$bytes_Buf_bytes_Bytes_ref_slice_u8, chain$bytes_Buf_ref_slice_u8_bytes_Bytes, chain$bytes_Buf_ref_slice_u8_bytes_BytesMut, advance$bytes_Buf_mut_bytes_Bytes as buf_impl_advance$bytes_Buf_mut_bytes_Bytes, advance$bytes_Buf_mut_collections_VecDeque_u8 as buf_impl_advance$bytes_Buf_mut_collections_VecDeque_u8, advance$bytes_Buf_mut_dyn_bytes_Buf as buf_impl_advance$bytes_Buf_mut_dyn_bytes_Buf, advance$bytes_Buf_mut_ref_slice_u8 as buf_impl_advance$bytes_Buf_mut_ref_slice_u8, chunksVectored$bytes_Buf_mut_ref_slice_u8 as buf_impl_chunksVectored$bytes_Buf_mut_ref_slice_u8, copyToBytes$bytes_Buf_mut_bytes_Bytes, copyToBytes$bytes_Buf_mut_collections_VecDeque_u8, copyToBytes$bytes_Buf_mut_dyn_bytes_Buf, copyToBytes$bytes_Buf_mut_ref_slice_u8, copyToSlice$bytes_Buf_mut_bytes_Bytes, copyToSlice$bytes_Buf_mut_collections_VecDeque_u8, copyToSlice$bytes_Buf_mut_dyn_bytes_Buf, copyToSlice$bytes_Buf_mut_ref_slice_u8, getF32Le$bytes_Buf_mut_bytes_Bytes, getF32Le$bytes_Buf_mut_collections_VecDeque_u8, getF32Le$bytes_Buf_mut_dyn_bytes_Buf, getF32Le$bytes_Buf_mut_ref_slice_u8, getF64$bytes_Buf_mut_bytes_Bytes, getF64$bytes_Buf_mut_collections_VecDeque_u8, getF64$bytes_Buf_mut_dyn_bytes_Buf, getF64$bytes_Buf_mut_ref_slice_u8, getI128$bytes_Buf_mut_bytes_Bytes, getI128$bytes_Buf_mut_collections_VecDeque_u8, getI128$bytes_Buf_mut_dyn_bytes_Buf, getI128$bytes_Buf_mut_ref_slice_u8, getI16Le$bytes_Buf_mut_bytes_Bytes, getI16Le$bytes_Buf_mut_collections_VecDeque_u8, getI16Le$bytes_Buf_mut_dyn_bytes_Buf, getI16Le$bytes_Buf_mut_ref_slice_u8, getI32$bytes_Buf_mut_bytes_Bytes, getI32$bytes_Buf_mut_collections_VecDeque_u8, getI32$bytes_Buf_mut_dyn_bytes_Buf, getI32$bytes_Buf_mut_ref_slice_u8, getI64Le$bytes_Buf_mut_bytes_Bytes, getI64Le$bytes_Buf_mut_collections_VecDeque_u8, getI64Le$bytes_Buf_mut_dyn_bytes_Buf, getI64Le$bytes_Buf_mut_ref_slice_u8, getI8$bytes_Buf_mut_bytes_Bytes, getI8$bytes_Buf_mut_collections_VecDeque_u8, getI8$bytes_Buf_mut_dyn_bytes_Buf, getI8$bytes_Buf_mut_ref_slice_u8, getIntLe$bytes_Buf_mut_bytes_Bytes, getIntLe$bytes_Buf_mut_collections_VecDeque_u8, getIntLe$bytes_Buf_mut_dyn_bytes_Buf, getIntLe$bytes_Buf_mut_ref_slice_u8, getU128Le$bytes_Buf_mut_bytes_Bytes, getU128Le$bytes_Buf_mut_collections_VecDeque_u8, getU128Le$bytes_Buf_mut_dyn_bytes_Buf, getU128Le$bytes_Buf_mut_ref_slice_u8, getU16$bytes_Buf_mut_bytes_Bytes, getU16$bytes_Buf_mut_collections_VecDeque_u8, getU16$bytes_Buf_mut_dyn_bytes_Buf, getU16$bytes_Buf_mut_ref_slice_u8, getU32Le$bytes_Buf_mut_bytes_Bytes, getU32Le$bytes_Buf_mut_collections_VecDeque_u8, getU32Le$bytes_Buf_mut_dyn_bytes_Buf, getU32Le$bytes_Buf_mut_ref_slice_u8, getU64$bytes_Buf_mut_bytes_Bytes, getU64$bytes_Buf_mut_collections_VecDeque_u8, getU64$bytes_Buf_mut_dyn_bytes_Buf, getU64$bytes_Buf_mut_ref_slice_u8, getU8$bytes_Buf_mut_bytes_Bytes, getU8$bytes_Buf_mut_collections_VecDeque_u8, getU8$bytes_Buf_mut_dyn_bytes_Buf, getU8$bytes_Buf_mut_ref_slice_u8, getUint$bytes_Buf_mut_bytes_Bytes, getUint$bytes_Buf_mut_collections_VecDeque_u8, getUint$bytes_Buf_mut_dyn_bytes_Buf, getUint$bytes_Buf_mut_ref_slice_u8, hasRemaining$bytes_Buf_mut_boxed_Box_dyn_bytes_Buf, hasRemaining$bytes_Buf_mut_bytes_Bytes, hasRemaining$bytes_Buf_mut_bytes_BytesMut, hasRemaining$bytes_Buf_mut_dyn_buf_Leased, hasRemaining$bytes_Buf_mut_dyn_bytes_Buf, hasRemaining$bytes_Buf_mut_mut_bytes_Bytes, hasRemaining$bytes_Buf_mut_mut_collections_VecDeque_u8, hasRemaining$bytes_Buf_mut_mut_dyn_bytes_Buf, hasRemaining$bytes_Buf_mut_mut_ref_slice_u8, hasRemaining$bytes_Buf_mut_ref_slice_u8, remaining$bytes_Buf_mut_boxed_Box_dyn_bytes_Buf as buf_impl_remaining$bytes_Buf_mut_boxed_Box_dyn_bytes_Buf, remaining$bytes_Buf_mut_bytes_Bytes as buf_impl_remaining$bytes_Buf_mut_bytes_Bytes, remaining$bytes_Buf_mut_bytes_BytesMut as buf_impl_remaining$bytes_Buf_mut_bytes_BytesMut, remaining$bytes_Buf_mut_dyn_buf_Leased as buf_impl_remaining$bytes_Buf_mut_dyn_buf_Leased, remaining$bytes_Buf_mut_dyn_bytes_Buf as buf_impl_remaining$bytes_Buf_mut_dyn_bytes_Buf, remaining$bytes_Buf_mut_mut_bytes_Bytes as buf_impl_remaining$bytes_Buf_mut_mut_bytes_Bytes, remaining$bytes_Buf_mut_mut_collections_VecDeque_u8 as buf_impl_remaining$bytes_Buf_mut_mut_collections_VecDeque_u8, remaining$bytes_Buf_mut_mut_dyn_bytes_Buf as buf_impl_remaining$bytes_Buf_mut_mut_dyn_bytes_Buf, remaining$bytes_Buf_mut_mut_ref_slice_u8 as buf_impl_remaining$bytes_Buf_mut_mut_ref_slice_u8, remaining$bytes_Buf_mut_ref_slice_u8 as buf_impl_remaining$bytes_Buf_mut_ref_slice_u8, tryGetI64Le$bytes_Buf_mut_bytes_Bytes, tryGetI64Le$bytes_Buf_mut_collections_VecDeque_u8, tryGetI64Le$bytes_Buf_mut_dyn_bytes_Buf, tryGetI64Le$bytes_Buf_mut_ref_slice_u8, tryGetU128$bytes_Buf_mut_bytes_Bytes, tryGetU128$bytes_Buf_mut_collections_VecDeque_u8, tryGetU128$bytes_Buf_mut_dyn_bytes_Buf, tryGetU128$bytes_Buf_mut_ref_slice_u8, tryGetU16$bytes_Buf_mut_bytes_Bytes, tryGetU16$bytes_Buf_mut_collections_VecDeque_u8, tryGetU16$bytes_Buf_mut_dyn_bytes_Buf, tryGetU16$bytes_Buf_mut_ref_slice_u8, tryGetU8$bytes_Buf_mut_bytes_Bytes, tryGetU8$bytes_Buf_mut_collections_VecDeque_u8, tryGetU8$bytes_Buf_mut_dyn_bytes_Buf, tryGetU8$bytes_Buf_mut_ref_slice_u8, advance$bytes_Buf_boxed_Box_dyn_bytes_Buf as buf_impl_advance$bytes_Buf_boxed_Box_dyn_bytes_Buf, chunksVectored$bytes_Buf_boxed_Box_dyn_bytes_Buf as buf_impl_chunksVectored$bytes_Buf_boxed_Box_dyn_bytes_Buf, copyToBytes$bytes_Buf_boxed_Box_dyn_bytes_Buf, copyToSlice$bytes_Buf_boxed_Box_dyn_bytes_Buf, getF32Le$bytes_Buf_boxed_Box_dyn_bytes_Buf, getF64$bytes_Buf_boxed_Box_dyn_bytes_Buf, getI128$bytes_Buf_boxed_Box_dyn_bytes_Buf, getI16Le$bytes_Buf_boxed_Box_dyn_bytes_Buf, getI16Ne$bytes_Buf_boxed_Box_dyn_bytes_Buf, getI32$bytes_Buf_boxed_Box_dyn_bytes_Buf, getI64Le$bytes_Buf_boxed_Box_dyn_bytes_Buf, getI8$bytes_Buf_boxed_Box_dyn_bytes_Buf, getIntLe$bytes_Buf_boxed_Box_dyn_bytes_Buf, getU128Le$bytes_Buf_boxed_Box_dyn_bytes_Buf, getU16$bytes_Buf_boxed_Box_dyn_bytes_Buf, getU32Le$bytes_Buf_boxed_Box_dyn_bytes_Buf, getU64$bytes_Buf_boxed_Box_dyn_bytes_Buf, getU8$bytes_Buf_boxed_Box_dyn_bytes_Buf, getUint$bytes_Buf_boxed_Box_dyn_bytes_Buf, remaining$bytes_Buf_boxed_Box_dyn_bytes_Buf as buf_impl_remaining$bytes_Buf_boxed_Box_dyn_bytes_Buf, tryGetI64Le$bytes_Buf_boxed_Box_dyn_bytes_Buf, tryGetU128$bytes_Buf_boxed_Box_dyn_bytes_Buf, tryGetU16$bytes_Buf_boxed_Box_dyn_bytes_Buf, tryGetU8$bytes_Buf_boxed_Box_dyn_bytes_Buf } from "./bytes/buf/buf_impl.ts"; import type * as Buf from "./bytes/buf/buf_impl.Buf.ts"; -import { advanceMut$bytes_BufMut_mut_Vec_u8, chunkMut$bytes_BufMut_mut_Vec_u8, putI16Le$bytes_BufMut_mut_Vec_u8, putI16Le$bytes_BufMut_mut_bytes_BytesMut, putI32Le$bytes_BufMut_mut_Vec_u8, putI32Le$bytes_BufMut_mut_bytes_BytesMut, putI64$bytes_BufMut_mut_Vec_u8, putI64$bytes_BufMut_mut_bytes_BytesMut, putI8$bytes_BufMut_mut_Vec_u8, putI8$bytes_BufMut_mut_bytes_BytesMut, putSlice$bytes_BufMut_mut_Vec_u8, putSlice$bytes_BufMut_mut_bytes_BytesMut, putU16$bytes_BufMut_mut_Vec_u8, putU16$bytes_BufMut_mut_bytes_BytesMut, putU32$bytes_BufMut_mut_Vec_u8, putU32$bytes_BufMut_mut_bytes_BytesMut, putU32Le$bytes_BufMut_mut_Vec_u8, putU64Le$bytes_BufMut_mut_Vec_u8, putU64Le$bytes_BufMut_mut_bytes_BytesMut, putU8$bytes_BufMut_mut_Vec_u8, putU8$bytes_BufMut_mut_bytes_BytesMut, remainingMut$bytes_BufMut_mut_Vec_u8, remainingMut$bytes_BufMut_mut_boxed_Box_Vec_u8, remainingMut$bytes_BufMut_mut_boxed_Box_bytes_BytesMut, remainingMut$bytes_BufMut_mut_boxed_Box_mut_bytes_BytesMut, remainingMut$bytes_BufMut_mut_bytes_BytesMut, remainingMut$bytes_BufMut_mut_mut_Vec_u8, remainingMut$bytes_BufMut_mut_mut_bytes_BytesMut, advanceMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, chunkMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, putI16Le$bytes_BufMut_boxed_Box_Vec_u8, putI16Le$bytes_BufMut_boxed_Box_bytes_BytesMut, putI32Le$bytes_BufMut_boxed_Box_Vec_u8, putI32Le$bytes_BufMut_boxed_Box_bytes_BytesMut, putI64$bytes_BufMut_boxed_Box_Vec_u8, putI64$bytes_BufMut_boxed_Box_bytes_BytesMut, putI8$bytes_BufMut_boxed_Box_Vec_u8, putI8$bytes_BufMut_boxed_Box_bytes_BytesMut, putSlice$bytes_BufMut_boxed_Box_Vec_u8, putSlice$bytes_BufMut_boxed_Box_bytes_BytesMut, putSlice$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, putU16$bytes_BufMut_boxed_Box_Vec_u8, putU16$bytes_BufMut_boxed_Box_bytes_BytesMut, putU32$bytes_BufMut_boxed_Box_Vec_u8, putU32$bytes_BufMut_boxed_Box_bytes_BytesMut, putU32Le$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, putU64Le$bytes_BufMut_boxed_Box_Vec_u8, putU64Le$bytes_BufMut_boxed_Box_bytes_BytesMut, putU8$bytes_BufMut_boxed_Box_Vec_u8, putU8$bytes_BufMut_boxed_Box_bytes_BytesMut } from "./bytes/buf/buf_mut.ts"; +import { hasRemainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8, hasRemainingMut$bytes_BufMut_mut_mut_mut_slice_u8, hasRemainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, hasRemainingMut$bytes_BufMut_mut_mut_slice_u8, put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Pieces as buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Pieces, put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Provided as buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Provided, put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes as buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes, put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut as buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut, put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8, put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8, put$bytes_BufMut_mut_mut_slice_u8_buf_Pieces as buf_mut_put$bytes_BufMut_mut_mut_slice_u8_buf_Pieces, put$bytes_BufMut_mut_mut_slice_u8_buf_Provided as buf_mut_put$bytes_BufMut_mut_mut_slice_u8_buf_Provided, put$bytes_BufMut_mut_mut_slice_u8_bytes_Bytes as buf_mut_put$bytes_BufMut_mut_mut_slice_u8_bytes_Bytes, put$bytes_BufMut_mut_mut_slice_u8_bytes_BytesMut as buf_mut_put$bytes_BufMut_mut_mut_slice_u8_bytes_BytesMut, put$bytes_BufMut_mut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8, put$bytes_BufMut_mut_mut_slice_u8_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_mut_slice_u8_ref_slice_u8, put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Pieces as buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Pieces, put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Provided as buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Provided, put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes as buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes, put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut as buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut, put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8, put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8, put$bytes_BufMut_mut_slice_u8_buf_Pieces as buf_mut_put$bytes_BufMut_mut_slice_u8_buf_Pieces, put$bytes_BufMut_mut_slice_u8_buf_Provided as buf_mut_put$bytes_BufMut_mut_slice_u8_buf_Provided, put$bytes_BufMut_mut_slice_u8_bytes_Bytes as buf_mut_put$bytes_BufMut_mut_slice_u8_bytes_Bytes, put$bytes_BufMut_mut_slice_u8_bytes_BytesMut as buf_mut_put$bytes_BufMut_mut_slice_u8_bytes_BytesMut, put$bytes_BufMut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8, put$bytes_BufMut_mut_slice_u8_ref_slice_u8 as buf_mut_put$bytes_BufMut_mut_slice_u8_ref_slice_u8, putBytes$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putBytes$bytes_BufMut_mut_mut_slice_u8, putU8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putU8$bytes_BufMut_mut_slice_u8, putI8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putI8$bytes_BufMut_mut_slice_u8, putU16$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putU16$bytes_BufMut_mut_slice_u8, putI16Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putI16Le$bytes_BufMut_mut_slice_u8, putU32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putU32$bytes_BufMut_mut_slice_u8, putU32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putU32Le$bytes_BufMut_mut_slice_u8, putI32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putI32Le$bytes_BufMut_mut_slice_u8, putU64Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putU64Le$bytes_BufMut_mut_slice_u8, putI64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putI64$bytes_BufMut_mut_slice_u8, putU128Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putU128Le$bytes_BufMut_mut_mut_slice_u8, putU128Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putU128Le$bytes_BufMut_mut_slice_u8, putUint$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putUint$bytes_BufMut_mut_mut_slice_u8, putUint$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putUint$bytes_BufMut_mut_slice_u8, putUintLe$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putUintLe$bytes_BufMut_mut_mut_slice_u8, putUintLe$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putUintLe$bytes_BufMut_mut_slice_u8, putInt$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putInt$bytes_BufMut_mut_mut_slice_u8, putInt$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putInt$bytes_BufMut_mut_slice_u8, putIntLe$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putIntLe$bytes_BufMut_mut_mut_slice_u8, putIntLe$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putIntLe$bytes_BufMut_mut_slice_u8, putF32$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putF32$bytes_BufMut_mut_mut_slice_u8, putF32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putF32$bytes_BufMut_mut_slice_u8, putF64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putF64$bytes_BufMut_mut_mut_slice_u8, putF64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putF64$bytes_BufMut_mut_slice_u8, advanceMut$bytes_BufMut_mut_Vec_u8, chunkMut$bytes_BufMut_mut_Vec_u8, putI16Le$bytes_BufMut_mut_Vec_u8, putI16Le$bytes_BufMut_mut_bytes_BytesMut, putI16Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putI16Le$bytes_BufMut_mut_mut_slice_u8, putI32Le$bytes_BufMut_mut_Vec_u8, putI32Le$bytes_BufMut_mut_bytes_BytesMut, putI32Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putI32Le$bytes_BufMut_mut_mut_slice_u8, putI64$bytes_BufMut_mut_Vec_u8, putI64$bytes_BufMut_mut_bytes_BytesMut, putI64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putI64$bytes_BufMut_mut_mut_slice_u8, putI8$bytes_BufMut_mut_Vec_u8, putI8$bytes_BufMut_mut_bytes_BytesMut, putI8$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putI8$bytes_BufMut_mut_mut_slice_u8, putSlice$bytes_BufMut_mut_Vec_u8, putSlice$bytes_BufMut_mut_bytes_BytesMut, putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putSlice$bytes_BufMut_mut_mut_slice_u8, putU16$bytes_BufMut_mut_Vec_u8, putU16$bytes_BufMut_mut_bytes_BytesMut, putU16$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putU16$bytes_BufMut_mut_mut_slice_u8, putU32$bytes_BufMut_mut_Vec_u8, putU32$bytes_BufMut_mut_bytes_BytesMut, putU32$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putU32$bytes_BufMut_mut_mut_slice_u8, putU32Le$bytes_BufMut_mut_Vec_u8, putU64Le$bytes_BufMut_mut_Vec_u8, putU64Le$bytes_BufMut_mut_bytes_BytesMut, putU64Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putU64Le$bytes_BufMut_mut_mut_slice_u8, putU8$bytes_BufMut_mut_Vec_u8, putU8$bytes_BufMut_mut_bytes_BytesMut, putU8$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, putU8$bytes_BufMut_mut_mut_slice_u8, remainingMut$bytes_BufMut_mut_Vec_u8, remainingMut$bytes_BufMut_mut_boxed_Box_Vec_u8, remainingMut$bytes_BufMut_mut_boxed_Box_bytes_BytesMut, remainingMut$bytes_BufMut_mut_boxed_Box_mut_bytes_BytesMut, remainingMut$bytes_BufMut_mut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8, remainingMut$bytes_BufMut_mut_boxed_Box_mut_mut_slice_u8, remainingMut$bytes_BufMut_mut_bytes_BytesMut, remainingMut$bytes_BufMut_mut_mut_Vec_u8, remainingMut$bytes_BufMut_mut_mut_bytes_BytesMut, remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8, remainingMut$bytes_BufMut_mut_mut_mut_slice_u8, remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8, remainingMut$bytes_BufMut_mut_mut_slice_u8, advanceMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, advanceMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8, advanceMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8, chunkMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, chunkMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8, chunkMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8, putI16Le$bytes_BufMut_boxed_Box_Vec_u8, putI16Le$bytes_BufMut_boxed_Box_bytes_BytesMut, putI32Le$bytes_BufMut_boxed_Box_Vec_u8, putI32Le$bytes_BufMut_boxed_Box_bytes_BytesMut, putI64$bytes_BufMut_boxed_Box_Vec_u8, putI64$bytes_BufMut_boxed_Box_bytes_BytesMut, putI8$bytes_BufMut_boxed_Box_Vec_u8, putI8$bytes_BufMut_boxed_Box_bytes_BytesMut, putSlice$bytes_BufMut_boxed_Box_Vec_u8, putSlice$bytes_BufMut_boxed_Box_bytes_BytesMut, putSlice$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, putSlice$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8, putSlice$bytes_BufMut_boxed_Box_mut_mut_slice_u8, putU16$bytes_BufMut_boxed_Box_Vec_u8, putU16$bytes_BufMut_boxed_Box_bytes_BytesMut, putU32$bytes_BufMut_boxed_Box_Vec_u8, putU32$bytes_BufMut_boxed_Box_bytes_BytesMut, putU32Le$bytes_BufMut_boxed_Box_mut_bytes_BytesMut, putU32Le$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8, putU32Le$bytes_BufMut_boxed_Box_mut_mut_slice_u8, putU64Le$bytes_BufMut_boxed_Box_Vec_u8, putU64Le$bytes_BufMut_boxed_Box_bytes_BytesMut, putU8$bytes_BufMut_boxed_Box_Vec_u8, putU8$bytes_BufMut_boxed_Box_bytes_BytesMut, chunkMut$bytes_BufMut_mut_slice_u8, advanceMut$bytes_BufMut_mut_slice_u8, putSlice$bytes_BufMut_mut_slice_u8, putBytes$bytes_BufMut_mut_slice_u8, chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8, putBytes$bytes_BufMut_mut_slice_mem_MaybeUninit_u8 } from "./bytes/buf/buf_mut.ts"; import * as Chain from "./bytes/buf/chain.Chain.ts"; import * as Take from "./bytes/buf/take.Take.ts"; import * as UninitSlice from "./bytes/buf/uninit_slice.UninitSlice.ts"; @@ -3194,6 +3194,94 @@ export function chunkAll$boxed_Box_mut_bytes_BytesMut(buf: rs.Place } } +/** + * A write through `buf`'s chunk by each pair of `data`'s bytes, of each range of it, and + * past it, which panics as `bytes` does, then `advance_mut` over what it wrote, or past + * the chunk, which panics too; or a provided write, which a writer of the crate's own + * makes through its chunk. + */ +export function chunkAll$boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(buf: rs.Place>, dataData: Uint8Array, dataStart: number, dataLen: number, out: rs.ByteVec): void { + let cnt!: rs.usize; + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const _16: rs.u8 = rs.u8Rem(op2, 13); + if (_16 === 10) { + const _18: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(n2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + putSlice$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(buf, _18); + } else if (_16 === 11) { + putU32Le$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.u32Mul(n2 as rs.u32, 16843009)); + } else { + const chunk: rs.ByteSlice = chunkMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(buf); + const room: rs.usize = UninitSlice.len(chunk); + const written: rs.usize = chunkWrite(chunk, op2, n2, out); + if (!(rs.u8Rem(n2, 16) === 15)) { + cnt = written; + } else { + cnt = rs.usizeAdd(room, 1); + } + advanceMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(buf, cnt); + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(room as rs.u32).reverse())); + } + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(remainingMut$bytes_BufMut_mut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(buf) as rs.u32).reverse())); + } +} + +/** + * A write through `buf`'s chunk by each pair of `data`'s bytes, of each range of it, and + * past it, which panics as `bytes` does, then `advance_mut` over what it wrote, or past + * the chunk, which panics too; or a provided write, which a writer of the crate's own + * makes through its chunk. + */ +export function chunkAll$boxed_Box_mut_mut_slice_u8(buf: rs.Place>, dataData: Uint8Array, dataStart: number, dataLen: number, out: rs.ByteVec): void { + let cnt!: rs.usize; + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const _16: rs.u8 = rs.u8Rem(op2, 13); + if (_16 === 10) { + const _18: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(n2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + putSlice$bytes_BufMut_boxed_Box_mut_mut_slice_u8(buf, _18); + } else if (_16 === 11) { + putU32Le$bytes_BufMut_boxed_Box_mut_mut_slice_u8(buf, rs.u32Mul(n2 as rs.u32, 16843009)); + } else { + const chunk: rs.ByteSlice = chunkMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8(buf); + const room: rs.usize = UninitSlice.len(chunk); + const written: rs.usize = chunkWrite(chunk, op2, n2, out); + if (!(rs.u8Rem(n2, 16) === 15)) { + cnt = written; + } else { + cnt = rs.usizeAdd(room, 1); + } + advanceMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8(buf, cnt); + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(room as rs.u32).reverse())); + } + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(remainingMut$bytes_BufMut_mut_boxed_Box_mut_mut_slice_u8(buf) as rs.u32).reverse())); + } +} + /** * A write through `buf`'s chunk by each pair of `data`'s bytes, of each range of it, and * past it, which panics as `bytes` does, then `advance_mut` over what it wrote, or past @@ -3370,6 +3458,94 @@ export function chunkAll$mut_Vec_u8(buf: rs.Place, dataData: Uint8Ar } } +/** + * A write through `buf`'s chunk by each pair of `data`'s bytes, of each range of it, and + * past it, which panics as `bytes` does, then `advance_mut` over what it wrote, or past + * the chunk, which panics too; or a provided write, which a writer of the crate's own + * makes through its chunk. + */ +export function chunkAll$mut_slice_mem_MaybeUninit_u8(buf: rs.Place, dataData: Uint8Array, dataStart: number, dataLen: number, out: rs.ByteVec): void { + let cnt!: rs.usize; + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const _16: rs.u8 = rs.u8Rem(op2, 13); + if (_16 === 10) { + const _18: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(n2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, _18); + } else if (_16 === 11) { + putU32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.u32Mul(n2 as rs.u32, 16843009)); + } else { + const chunk: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf); + const room: rs.usize = UninitSlice.len(chunk); + const written: rs.usize = chunkWrite(chunk, op2, n2, out); + if (!(rs.u8Rem(n2, 16) === 15)) { + cnt = written; + } else { + cnt = rs.usizeAdd(room, 1); + } + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, cnt); + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(room as rs.u32).reverse())); + } + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf) as rs.u32).reverse())); + } +} + +/** + * A write through `buf`'s chunk by each pair of `data`'s bytes, of each range of it, and + * past it, which panics as `bytes` does, then `advance_mut` over what it wrote, or past + * the chunk, which panics too; or a provided write, which a writer of the crate's own + * makes through its chunk. + */ +export function chunkAll$mut_slice_u8(buf: rs.Place, dataData: Uint8Array, dataStart: number, dataLen: number, out: rs.ByteVec): void { + let cnt!: rs.usize; + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const _16: rs.u8 = rs.u8Rem(op2, 13); + if (_16 === 10) { + const _18: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(n2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + putSlice$bytes_BufMut_mut_slice_u8(buf, _18); + } else if (_16 === 11) { + putU32Le$bytes_BufMut_mut_slice_u8(buf, rs.u32Mul(n2 as rs.u32, 16843009)); + } else { + const chunk: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_u8(buf); + const room: rs.usize = UninitSlice.len(chunk); + const written: rs.usize = chunkWrite(chunk, op2, n2, out); + if (!(rs.u8Rem(n2, 16) === 15)) { + cnt = written; + } else { + cnt = rs.usizeAdd(room, 1); + } + advanceMut$bytes_BufMut_mut_slice_u8(buf, cnt); + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(room as rs.u32).reverse())); + } + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(rs.u32ToBeBytes(remainingMut$bytes_BufMut_mut_mut_slice_u8(buf) as rs.u32).reverse())); + } +} + /** A write into `chunk` that `op` picks, of `n`'s bytes: how many from its front it wrote. */ export function chunkWrite(chunk: rs.ByteSlice, op: rs.u8, n: rs.u8, out: rs.ByteVec): rs.usize { const room: rs.usize = UninitSlice.len(chunk); @@ -3391,7 +3567,7 @@ export function chunkWrite(chunk: rs.ByteSlice, op: rs.u8, n: rs.u8, out: rs.Byt } } if (_20 === 1) { - UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(chunk, { end: k }, { file: "fixtures/stock/src/buf.rs", line: 701, col: 19 }), rs.byteVecSlice(src)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(chunk, { end: k }, { file: "fixtures/stock/src/buf.rs", line: 702, col: 19 }), rs.byteVecSlice(src)); break b1; } if (_20 === 2) { @@ -3403,46 +3579,46 @@ export function chunkWrite(chunk: rs.ByteSlice, op: rs.u8, n: rs.u8, out: rs.Byt break b1; } if (_20 === 4) { - UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(UninitSlice.indexMut$ops_IndexMut_ops_RangeFrom_usize(chunk, new rs.RangeFrom(half, rs.usizeStep), { file: "fixtures/stock/src/buf.rs", line: 709, col: 18 }), { end: rs.usizeSub(k, half) }, { file: "fixtures/stock/src/buf.rs", line: 709, col: 26 }), rs.byteSliceRange(rs.byteVecSlice(src), half)); - UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_Range_usize(chunk, new rs.Range(0, half), { file: "fixtures/stock/src/buf.rs", line: 710, col: 18 }), rs.byteSliceRange(rs.byteVecSlice(src), 0, half)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(UninitSlice.indexMut$ops_IndexMut_ops_RangeFrom_usize(chunk, new rs.RangeFrom(half, rs.usizeStep), { file: "fixtures/stock/src/buf.rs", line: 710, col: 18 }), { end: rs.usizeSub(k, half) }, { file: "fixtures/stock/src/buf.rs", line: 710, col: 26 }), rs.byteSliceRange(rs.byteVecSlice(src), half)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_Range_usize(chunk, new rs.Range(0, half), { file: "fixtures/stock/src/buf.rs", line: 711, col: 18 }), rs.byteSliceRange(rs.byteVecSlice(src), 0, half)); break b1; } if (_20 === 5) { if (k > 0) { const _66: { end: rs.usize; inclusive: true } = { end: rs.usizeSub(k, 1), inclusive: true }; - UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeToInclusive_usize(chunk, _66, { file: "fixtures/stock/src/buf.rs", line: 713, col: 18 }), rs.byteVecSlice(src)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeToInclusive_usize(chunk, _66, { file: "fixtures/stock/src/buf.rs", line: 714, col: 18 }), rs.byteVecSlice(src)); const _73: rs.RangeInclusive = new rs.RangeInclusive(half, half, rs.usizeStep); - UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_RangeInclusive_usize(chunk, _73, { file: "fixtures/stock/src/buf.rs", line: 714, col: 18 }), 0, ~n & 0xff); + UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_RangeInclusive_usize(chunk, _73, { file: "fixtures/stock/src/buf.rs", line: 715, col: 18 }), 0, ~n & 0xff); break b1; } } else { if (_20 === 6) { - UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(UninitSlice.indexMut$ops_IndexMut_ops_RangeFull(chunk, undefined, { file: "fixtures/stock/src/buf.rs", line: 716, col: 19 }), { end: k }, { file: "fixtures/stock/src/buf.rs", line: 716, col: 23 }), rs.byteVecSlice(src)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(UninitSlice.indexMut$ops_IndexMut_ops_RangeFull(chunk, undefined, { file: "fixtures/stock/src/buf.rs", line: 717, col: 19 }), { end: k }, { file: "fixtures/stock/src/buf.rs", line: 717, col: 23 }), rs.byteVecSlice(src)); break b1; } if (_20 === 7) { - UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_RangeFrom_usize(chunk, new rs.RangeFrom(k, rs.usizeStep), { file: "fixtures/stock/src/buf.rs", line: 719, col: 18 }), 0, n); - UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(chunk, { end: k }, { file: "fixtures/stock/src/buf.rs", line: 720, col: 18 }), rs.byteVecSlice(src)); + UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_RangeFrom_usize(chunk, new rs.RangeFrom(k, rs.usizeStep), { file: "fixtures/stock/src/buf.rs", line: 720, col: 18 }), 0, n); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(chunk, { end: k }, { file: "fixtures/stock/src/buf.rs", line: 721, col: 18 }), rs.byteVecSlice(src)); return rs.usizeAdd(k, 1); } if (_20 === 8) { - UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(chunk, { end: k }, { file: "fixtures/stock/src/buf.rs", line: 724, col: 19 }), rs.byteSliceFrom(rs.bytes(3).fill(n))); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(chunk, { end: k }, { file: "fixtures/stock/src/buf.rs", line: 725, col: 19 }), rs.byteSliceFrom(rs.bytes(3).fill(n))); break b1; } if (_20 === 9) { const _94: rs.u8 = rs.u8Rem(n, 3); if (_94 === 0) { const _100: { end: rs.usize } = { end: rs.usizeAdd(room, 1) }; - rs.byteVecPush(out, UninitSlice.len(UninitSlice.index$ops_Index_ops_RangeTo_usize(chunk, _100, { file: "fixtures/stock/src/buf.rs", line: 727, col: 32 })) & 0xff); + rs.byteVecPush(out, UninitSlice.len(UninitSlice.index$ops_Index_ops_RangeTo_usize(chunk, _100, { file: "fixtures/stock/src/buf.rs", line: 728, col: 32 })) & 0xff); break b1; } if (_94 === 1) { const _104: rs.Range = new rs.Range(rs.usizeAdd(k, 1), k); - UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_Range_usize(chunk, _104, { file: "fixtures/stock/src/buf.rs", line: 728, col: 23 }), 0, n); + UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_Range_usize(chunk, _104, { file: "fixtures/stock/src/buf.rs", line: 729, col: 23 }), 0, n); break b1; } const _108: rs.RangeFrom = new rs.RangeFrom(rs.usizeAdd(room, 1), rs.usizeStep); - UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_RangeFrom_usize(chunk, _108, { file: "fixtures/stock/src/buf.rs", line: 729, col: 23 }), 0, n); + UninitSlice.writeByte(UninitSlice.indexMut$ops_IndexMut_ops_RangeFrom_usize(chunk, _108, { file: "fixtures/stock/src/buf.rs", line: 730, col: 23 }), 0, n); break b1; } } @@ -3452,6 +3628,64 @@ export function chunkWrite(chunk: rs.ByteSlice, op: rs.u8, n: rs.u8, out: rs.Byt return k; } +/** + * Writes into an array through a `&mut [u8]` and a `&mut [MaybeUninit]` of the room + * its input picks, which write at the front and advance past what they wrote, or panic + * past the room, directly, through a `&mut`, and through a `Box`: the room left, then + * each array whole, so a write that missed it or landed off the front would show. + */ +export function slices(dataData: Uint8Array, dataStart: number, dataLen: number, out: rs.ByteVec): void { + let left!: rs.usize; + if (dataLen >= 2) { + const room: rs.usize = dataData[dataStart + 1] as rs.usize; + const bytes: Uint8Array = rs.bytes(255).fill(165); + const uninit: Uint8Array = rs.bytes(255).fill(90); + const _14: rs.u8 = rs.u8Rem(dataData[dataStart], 8); + if (_14 === 0) { + let s: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(bytes), 0, room); + writeAll$mut_slice_u8(rs.place(() => s, (value12) => s = value12), dataData, dataStart + 2, dataLen - 2); + left = s.length; + } else if (_14 === 1) { + let s2: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(bytes), 0, room); + chunkAll$mut_slice_u8(rs.place(() => s2, (value11) => s2 = value11), dataData, dataStart + 2, dataLen - 2, out); + left = s2.length; + } else if (_14 === 2) { + let s3: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(uninit), 0, room); + writeAll$mut_slice_mem_MaybeUninit_u8(rs.place(() => s3, (value10) => s3 = value10), dataData, dataStart + 2, dataLen - 2); + left = s3.length; + } else if (_14 === 3) { + let s4: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(uninit), 0, room); + chunkAll$mut_slice_mem_MaybeUninit_u8(rs.place(() => s4, (value9) => s4 = value9), dataData, dataStart + 2, dataLen - 2, out); + left = s4.length; + } else if (_14 === 4) { + let s5: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(bytes), 0, room); + let _49: rs.Place = rs.place(() => s5, (value7) => s5 = value7); + writeAll$mut_mut_slice_u8(rs.place(() => _49, (value8) => _49 = value8), dataData, dataStart + 2, dataLen - 2); + left = s5.length; + } else if (_14 === 5) { + let s6: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(uninit), 0, room); + let _57: rs.Place = rs.place(() => s6, (value5) => s6 = value5); + chunkAll$boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(rs.place(() => _57, (value6) => _57 = value6), dataData, dataStart + 2, dataLen - 2, out); + left = s6.length; + } else if (_14 === 6) { + let s7: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(bytes), 0, room); + let _66: rs.Place = rs.place(() => s7, (value3) => s7 = value3); + chunkAll$boxed_Box_mut_mut_slice_u8(rs.place(() => _66, (value4) => _66 = value4), dataData, dataStart + 2, dataLen - 2, out); + left = s7.length; + } else { + let s8: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(uninit), 0, room); + let _75: rs.Place = rs.place(() => s8, (value) => s8 = value); + writeAll$mut_mut_slice_mem_MaybeUninit_u8(rs.place(() => _75, (value2) => _75 = value2), dataData, dataStart + 2, dataLen - 2); + left = s8.length; + } + rs.byteVecPush(out, left & 0xff); + rs.byteVecExtendFromSlice(out, rs.byteSliceFrom(bytes)); + rs.iterExtendBytes(out, rs.iterMap(rs.iterSlice(rs.byteSliceView(rs.byteSliceFrom(uninit))), (b: rs.u8): rs.u8 => { + return b; + }), undefined, true); + } +} + /** * The same writes into a `Vec` and a `BytesMut`, which must match, and through the * impls forwarding through a `&mut` and a `Box`, whose provided `put` and `put_bytes` @@ -4130,6 +4364,338 @@ export function writeAll$mut_bytes_BytesMut(buf: rs.Place, dataData } } +/** A write by each pair of `data`'s bytes, one past what a vector holds included. */ +export function writeAll$mut_mut_slice_mem_MaybeUninit_u8(buf: rs.Place>, dataData: Uint8Array, dataStart: number, dataLen: number): void { + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const v: rs.u64 = rs.u64Mul(n2 as rs.u64, { hi: 0x1010101, lo: 0x1010101 } as rs.u64); + const _18: rs.u8 = rs.u8Rem(op2, 23); + if (_18 === 0) { + putU8$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, n2); + } else if (_18 === 1) { + putI8$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, (n2 << 24) >> 24); + } else if (_18 === 2) { + putU16$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.u64Low(v) & 0xffff); + } else if (_18 === 3) { + putI16Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, (rs.u64Low(v) << 16) >> 16); + } else if (_18 === 4) { + putU32$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.u64Low(v)); + } else if (_18 === 5) { + putI32Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.u64Low(v) | 0); + } else if (_18 === 6) { + putU64Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, v); + } else if (_18 === 7) { + putI64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.i64Cast(v)); + } else if (_18 === 8) { + putU128Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.u128Shl(rs.u128Cast(v), 40)); + } else if (_18 === 9) { + putUint$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 10) { + putIntLe$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 11) { + putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.byteSliceFrom(Uint8Array.of(op2, n2))); + } else if (_18 === 12) { + if (!(n2 === 255)) { + putBytes$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, n2, rs.usizeRem(n2 as rs.usize, 100)); + } else { + putBytes$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, n2, 4294967295); + } + } else if (_18 === 13) { + const _44: rs.ByteSlice = rs.bytesStatic(rs.byteSliceFrom(Uint8Array.of(112, 117, 116))); + buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes(buf, _44); + } else if (_18 === 14) { + const _47: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(op2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8(buf, _47); + } else if (_18 === 15) { + const _54: rs.BytesMut = rs.bytesMutFrom(rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(3).fill(n2)), 0)); + buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut(buf, _54); + } else if (_18 === 16) { + const _58: rs.f32 = Math.fround(Math.fround(n2) / 3.0); + putF32$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, _58); + } else if (_18 === 17) { + putInt$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 18) { + putUintLe$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 19) { + putF64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, (n2 as rs.f64) / 3.0); + } else if (_18 === 20) { + const _70: rs.ByteSlice = rs.byteSliceFrom(Uint8Array.of(op2, n2, op2)); + const _69: Pieces.Pieces = Pieces.new(_70.data, _70.start, _70.length, rs.usizeRem(n2 as rs.usize, 4)); + buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Pieces(buf, _69); + } else if (_18 === 21) { + const _78: rs.ByteSlice = rs.byteSliceFrom(rs.bytes(5).fill(n2)); + const _76: Provided.Provided = { _0: Pieces.new(_78.data, _78.start, _78.length, rs.usizeRem(n2 as rs.usize, 6)) }; + buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Provided(buf, _76); + } else { + const _84: Chain.Chain = chain$bytes_Buf_bytes_Bytes_ref_slice_u8(rs.bytesCopyFromSlice(rs.byteSliceFrom(rs.bytes(2).fill(n2))), rs.byteSliceRange(rs.byteSliceFrom(Uint8Array.of(op2)), 0, rs.usizeRem(n2 as rs.usize, 2))); + buf_mut_put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(buf, _84); + } + const _97: rs.u8 = rs.u8Add(hasRemainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(buf) ? 1 : 0, rs.usizeRem(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(buf), 7) & 0xff); + putU8$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf, _97); + } +} + +/** A write by each pair of `data`'s bytes, one past what a vector holds included. */ +export function writeAll$mut_mut_slice_u8(buf: rs.Place>, dataData: Uint8Array, dataStart: number, dataLen: number): void { + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const v: rs.u64 = rs.u64Mul(n2 as rs.u64, { hi: 0x1010101, lo: 0x1010101 } as rs.u64); + const _18: rs.u8 = rs.u8Rem(op2, 23); + if (_18 === 0) { + putU8$bytes_BufMut_mut_mut_slice_u8(buf, n2); + } else if (_18 === 1) { + putI8$bytes_BufMut_mut_mut_slice_u8(buf, (n2 << 24) >> 24); + } else if (_18 === 2) { + putU16$bytes_BufMut_mut_mut_slice_u8(buf, rs.u64Low(v) & 0xffff); + } else if (_18 === 3) { + putI16Le$bytes_BufMut_mut_mut_slice_u8(buf, (rs.u64Low(v) << 16) >> 16); + } else if (_18 === 4) { + putU32$bytes_BufMut_mut_mut_slice_u8(buf, rs.u64Low(v)); + } else if (_18 === 5) { + putI32Le$bytes_BufMut_mut_mut_slice_u8(buf, rs.u64Low(v) | 0); + } else if (_18 === 6) { + putU64Le$bytes_BufMut_mut_mut_slice_u8(buf, v); + } else if (_18 === 7) { + putI64$bytes_BufMut_mut_mut_slice_u8(buf, rs.i64Cast(v)); + } else if (_18 === 8) { + putU128Le$bytes_BufMut_mut_mut_slice_u8(buf, rs.u128Shl(rs.u128Cast(v), 40)); + } else if (_18 === 9) { + putUint$bytes_BufMut_mut_mut_slice_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 10) { + putIntLe$bytes_BufMut_mut_mut_slice_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 11) { + putSlice$bytes_BufMut_mut_mut_slice_u8(buf, rs.byteSliceFrom(Uint8Array.of(op2, n2))); + } else if (_18 === 12) { + if (!(n2 === 255)) { + putBytes$bytes_BufMut_mut_mut_slice_u8(buf, n2, rs.usizeRem(n2 as rs.usize, 100)); + } else { + putBytes$bytes_BufMut_mut_mut_slice_u8(buf, n2, 4294967295); + } + } else if (_18 === 13) { + const _44: rs.ByteSlice = rs.bytesStatic(rs.byteSliceFrom(Uint8Array.of(112, 117, 116))); + buf_mut_put$bytes_BufMut_mut_mut_slice_u8_bytes_Bytes(buf, _44); + } else if (_18 === 14) { + const _47: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(op2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + buf_mut_put$bytes_BufMut_mut_mut_slice_u8_ref_slice_u8(buf, _47); + } else if (_18 === 15) { + const _54: rs.BytesMut = rs.bytesMutFrom(rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(3).fill(n2)), 0)); + buf_mut_put$bytes_BufMut_mut_mut_slice_u8_bytes_BytesMut(buf, _54); + } else if (_18 === 16) { + const _58: rs.f32 = Math.fround(Math.fround(n2) / 3.0); + putF32$bytes_BufMut_mut_mut_slice_u8(buf, _58); + } else if (_18 === 17) { + putInt$bytes_BufMut_mut_mut_slice_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 18) { + putUintLe$bytes_BufMut_mut_mut_slice_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 19) { + putF64$bytes_BufMut_mut_mut_slice_u8(buf, (n2 as rs.f64) / 3.0); + } else if (_18 === 20) { + const _70: rs.ByteSlice = rs.byteSliceFrom(Uint8Array.of(op2, n2, op2)); + const _69: Pieces.Pieces = Pieces.new(_70.data, _70.start, _70.length, rs.usizeRem(n2 as rs.usize, 4)); + buf_mut_put$bytes_BufMut_mut_mut_slice_u8_buf_Pieces(buf, _69); + } else if (_18 === 21) { + const _78: rs.ByteSlice = rs.byteSliceFrom(rs.bytes(5).fill(n2)); + const _76: Provided.Provided = { _0: Pieces.new(_78.data, _78.start, _78.length, rs.usizeRem(n2 as rs.usize, 6)) }; + buf_mut_put$bytes_BufMut_mut_mut_slice_u8_buf_Provided(buf, _76); + } else { + const _84: Chain.Chain = chain$bytes_Buf_bytes_Bytes_ref_slice_u8(rs.bytesCopyFromSlice(rs.byteSliceFrom(rs.bytes(2).fill(n2))), rs.byteSliceRange(rs.byteSliceFrom(Uint8Array.of(op2)), 0, rs.usizeRem(n2 as rs.usize, 2))); + buf_mut_put$bytes_BufMut_mut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(buf, _84); + } + const _97: rs.u8 = rs.u8Add(hasRemainingMut$bytes_BufMut_mut_mut_mut_slice_u8(buf) ? 1 : 0, rs.usizeRem(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(buf), 7) & 0xff); + putU8$bytes_BufMut_mut_mut_slice_u8(buf, _97); + } +} + +/** A write by each pair of `data`'s bytes, one past what a vector holds included. */ +export function writeAll$mut_slice_mem_MaybeUninit_u8(buf: rs.Place, dataData: Uint8Array, dataStart: number, dataLen: number): void { + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const v: rs.u64 = rs.u64Mul(n2 as rs.u64, { hi: 0x1010101, lo: 0x1010101 } as rs.u64); + const _18: rs.u8 = rs.u8Rem(op2, 23); + if (_18 === 0) { + putU8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, n2); + } else if (_18 === 1) { + putI8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, (n2 << 24) >> 24); + } else if (_18 === 2) { + putU16$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.u64Low(v) & 0xffff); + } else if (_18 === 3) { + putI16Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, (rs.u64Low(v) << 16) >> 16); + } else if (_18 === 4) { + putU32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.u64Low(v)); + } else if (_18 === 5) { + putI32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.u64Low(v) | 0); + } else if (_18 === 6) { + putU64Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, v); + } else if (_18 === 7) { + putI64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.i64Cast(v)); + } else if (_18 === 8) { + putU128Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.u128Shl(rs.u128Cast(v), 40)); + } else if (_18 === 9) { + putUint$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 10) { + putIntLe$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 11) { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.byteSliceFrom(Uint8Array.of(op2, n2))); + } else if (_18 === 12) { + if (!(n2 === 255)) { + putBytes$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, n2, rs.usizeRem(n2 as rs.usize, 100)); + } else { + putBytes$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, n2, 4294967295); + } + } else if (_18 === 13) { + const _44: rs.ByteSlice = rs.bytesStatic(rs.byteSliceFrom(Uint8Array.of(112, 117, 116))); + buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes(buf, _44); + } else if (_18 === 14) { + const _47: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(op2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8(buf, _47); + } else if (_18 === 15) { + const _54: rs.BytesMut = rs.bytesMutFrom(rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(3).fill(n2)), 0)); + buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut(buf, _54); + } else if (_18 === 16) { + const _58: rs.f32 = Math.fround(Math.fround(n2) / 3.0); + putF32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, _58); + } else if (_18 === 17) { + putInt$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 18) { + putUintLe$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 19) { + putF64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, (n2 as rs.f64) / 3.0); + } else if (_18 === 20) { + const _70: rs.ByteSlice = rs.byteSliceFrom(Uint8Array.of(op2, n2, op2)); + const _69: Pieces.Pieces = Pieces.new(_70.data, _70.start, _70.length, rs.usizeRem(n2 as rs.usize, 4)); + buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Pieces(buf, _69); + } else if (_18 === 21) { + const _78: rs.ByteSlice = rs.byteSliceFrom(rs.bytes(5).fill(n2)); + const _76: Provided.Provided = { _0: Pieces.new(_78.data, _78.start, _78.length, rs.usizeRem(n2 as rs.usize, 6)) }; + buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Provided(buf, _76); + } else { + const _84: Chain.Chain = chain$bytes_Buf_bytes_Bytes_ref_slice_u8(rs.bytesCopyFromSlice(rs.byteSliceFrom(rs.bytes(2).fill(n2))), rs.byteSliceRange(rs.byteSliceFrom(Uint8Array.of(op2)), 0, rs.usizeRem(n2 as rs.usize, 2))); + buf_mut_put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(buf, _84); + } + const _97: rs.u8 = rs.u8Add(hasRemainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf) ? 1 : 0, rs.usizeRem(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(buf), 7) & 0xff); + putU8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(buf, _97); + } +} + +/** A write by each pair of `data`'s bytes, one past what a vector holds included. */ +export function writeAll$mut_slice_u8(buf: rs.Place, dataData: Uint8Array, dataStart: number, dataLen: number): void { + let dataData2: Uint8Array = dataData; + let dataStart2: number = dataStart; + let dataLen2: number = dataLen; + while (dataLen2 >= 2) { + const op: rs.u8 = dataData2[dataStart2]; + const n: rs.u8 = dataData2[dataStart2 + 1]; + const restData: Uint8Array = dataData2; + const restStart: number = dataStart2 + 2; + const restLen: number = dataLen2 - 2; + dataData2 = restData; + dataStart2 = restStart; + dataLen2 = restLen; + const op2: rs.u8 = op; + const n2: rs.u8 = n; + const v: rs.u64 = rs.u64Mul(n2 as rs.u64, { hi: 0x1010101, lo: 0x1010101 } as rs.u64); + const _18: rs.u8 = rs.u8Rem(op2, 23); + if (_18 === 0) { + putU8$bytes_BufMut_mut_slice_u8(buf, n2); + } else if (_18 === 1) { + putI8$bytes_BufMut_mut_slice_u8(buf, (n2 << 24) >> 24); + } else if (_18 === 2) { + putU16$bytes_BufMut_mut_slice_u8(buf, rs.u64Low(v) & 0xffff); + } else if (_18 === 3) { + putI16Le$bytes_BufMut_mut_slice_u8(buf, (rs.u64Low(v) << 16) >> 16); + } else if (_18 === 4) { + putU32$bytes_BufMut_mut_slice_u8(buf, rs.u64Low(v)); + } else if (_18 === 5) { + putI32Le$bytes_BufMut_mut_slice_u8(buf, rs.u64Low(v) | 0); + } else if (_18 === 6) { + putU64Le$bytes_BufMut_mut_slice_u8(buf, v); + } else if (_18 === 7) { + putI64$bytes_BufMut_mut_slice_u8(buf, rs.i64Cast(v)); + } else if (_18 === 8) { + putU128Le$bytes_BufMut_mut_slice_u8(buf, rs.u128Shl(rs.u128Cast(v), 40)); + } else if (_18 === 9) { + putUint$bytes_BufMut_mut_slice_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 10) { + putIntLe$bytes_BufMut_mut_slice_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 11) { + putSlice$bytes_BufMut_mut_slice_u8(buf, rs.byteSliceFrom(Uint8Array.of(op2, n2))); + } else if (_18 === 12) { + if (!(n2 === 255)) { + putBytes$bytes_BufMut_mut_slice_u8(buf, n2, rs.usizeRem(n2 as rs.usize, 100)); + } else { + putBytes$bytes_BufMut_mut_slice_u8(buf, n2, 4294967295); + } + } else if (_18 === 13) { + const _44: rs.ByteSlice = rs.bytesStatic(rs.byteSliceFrom(Uint8Array.of(112, 117, 116))); + buf_mut_put$bytes_BufMut_mut_slice_u8_bytes_Bytes(buf, _44); + } else if (_18 === 14) { + const _47: rs.ByteSlice = rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(70).fill(op2)), 0, rs.usizeRem(n2 as rs.usize, 71)); + buf_mut_put$bytes_BufMut_mut_slice_u8_ref_slice_u8(buf, _47); + } else if (_18 === 15) { + const _54: rs.BytesMut = rs.bytesMutFrom(rs.byteSliceRange(rs.byteSliceFrom(rs.bytes(3).fill(n2)), 0)); + buf_mut_put$bytes_BufMut_mut_slice_u8_bytes_BytesMut(buf, _54); + } else if (_18 === 16) { + const _58: rs.f32 = Math.fround(Math.fround(n2) / 3.0); + putF32$bytes_BufMut_mut_slice_u8(buf, _58); + } else if (_18 === 17) { + putInt$bytes_BufMut_mut_slice_u8(buf, rs.i64Cast(v), rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 18) { + putUintLe$bytes_BufMut_mut_slice_u8(buf, v, rs.usizeRem(n2 as rs.usize, 10)); + } else if (_18 === 19) { + putF64$bytes_BufMut_mut_slice_u8(buf, (n2 as rs.f64) / 3.0); + } else if (_18 === 20) { + const _70: rs.ByteSlice = rs.byteSliceFrom(Uint8Array.of(op2, n2, op2)); + const _69: Pieces.Pieces = Pieces.new(_70.data, _70.start, _70.length, rs.usizeRem(n2 as rs.usize, 4)); + buf_mut_put$bytes_BufMut_mut_slice_u8_buf_Pieces(buf, _69); + } else if (_18 === 21) { + const _78: rs.ByteSlice = rs.byteSliceFrom(rs.bytes(5).fill(n2)); + const _76: Provided.Provided = { _0: Pieces.new(_78.data, _78.start, _78.length, rs.usizeRem(n2 as rs.usize, 6)) }; + buf_mut_put$bytes_BufMut_mut_slice_u8_buf_Provided(buf, _76); + } else { + const _84: Chain.Chain = chain$bytes_Buf_bytes_Bytes_ref_slice_u8(rs.bytesCopyFromSlice(rs.byteSliceFrom(rs.bytes(2).fill(n2))), rs.byteSliceRange(rs.byteSliceFrom(Uint8Array.of(op2)), 0, rs.usizeRem(n2 as rs.usize, 2))); + buf_mut_put$bytes_BufMut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(buf, _84); + } + const _97: rs.u8 = rs.u8Add(hasRemainingMut$bytes_BufMut_mut_mut_slice_u8(buf) ? 1 : 0, rs.usizeRem(remainingMut$bytes_BufMut_mut_mut_slice_u8(buf), 7) & 0xff); + putU8$bytes_BufMut_mut_slice_u8(buf, _97); + } +} + /** * `Bytes`' own edits, through a `&mut`, and `slice_ref` of a part of it, and whether each * part is the last handle of the storage: a promotable `Bytes` truncated to nothing gives diff --git a/ts/fixtures/stock/expected/bytes/buf/buf_mut.ts b/ts/fixtures/stock/expected/bytes/buf/buf_mut.ts index b36861b8c..fefbb1ce1 100644 --- a/ts/fixtures/stock/expected/bytes/buf/buf_mut.ts +++ b/ts/fixtures/stock/expected/bytes/buf/buf_mut.ts @@ -1,205 +1,112 @@ // Generated by rust2-ts. Do not edit. import * as rs from "../../rs.ts"; +import { drop$bytes_buf_Chain_bytes_Bytes_ref_slice_u8 as lib_drop$bytes_buf_Chain_bytes_Bytes_ref_slice_u8 } from "../../lib.ts"; +import * as Pieces from "../../buf.Pieces.ts"; +import * as Provided from "../../buf.Provided.ts"; +import { panicAdvance, panicDoesNotFit } from "../../bytes.ts"; +import * as Chain from "../../bytes/buf/chain.Chain.ts"; +import * as UninitSlice from "../../bytes/buf/uninit_slice.UninitSlice.ts"; /** - * Advance the internal cursor of the BufMut - * - * The next call to `chunk_mut` will return a slice starting `cnt` bytes - * further into the underlying buffer. + * Returns true if there is space in `self` for more bytes. * - * # Safety - * - * The caller must ensure that the next `cnt` bytes of `chunk` are - * initialized. + * This is equivalent to `self.remaining_mut() != 0`. * * # Examples * * ``` * use bytes::BufMut; * - * let mut buf = Vec::with_capacity(16); - * - * // Write some data - * buf.chunk_mut()[0..2].copy_from_slice(b"he"); - * unsafe { buf.advance_mut(2) }; + * let mut dst = [0; 5]; + * let mut buf = &mut dst[..]; * - * // write more bytes - * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * assert!(buf.has_remaining_mut()); * - * unsafe { buf.advance_mut(3); } + * buf.put(&b"hello"[..]); * - * assert_eq!(5, buf.len()); - * assert_eq!(buf, b"hello"); + * assert!(!buf.has_remaining_mut()); * ``` - * - * # Panics - * - * This function **may** panic if `cnt > self.remaining_mut()`. - * - * # Implementer notes - * - * It is recommended for implementations of `advance_mut` to panic if - * `cnt > self.remaining_mut()`. If the implementation does not panic, - * the call must behave as if `cnt == self.remaining_mut()`. - * - * A call with `cnt == 0` should never panic and be a no-op. */ -export function advanceMut$bytes_BufMut_mut_Vec_u8(self: rs.Place, cnt: rs.usize): void { - rs.byteVecAdvanceMut(self.v, cnt); +export function hasRemainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>): boolean { + return remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) > 0; } /** - * Advance the internal cursor of the BufMut - * - * The next call to `chunk_mut` will return a slice starting `cnt` bytes - * further into the underlying buffer. - * - * # Safety + * Returns true if there is space in `self` for more bytes. * - * The caller must ensure that the next `cnt` bytes of `chunk` are - * initialized. + * This is equivalent to `self.remaining_mut() != 0`. * * # Examples * * ``` * use bytes::BufMut; * - * let mut buf = Vec::with_capacity(16); - * - * // Write some data - * buf.chunk_mut()[0..2].copy_from_slice(b"he"); - * unsafe { buf.advance_mut(2) }; + * let mut dst = [0; 5]; + * let mut buf = &mut dst[..]; * - * // write more bytes - * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * assert!(buf.has_remaining_mut()); * - * unsafe { buf.advance_mut(3); } + * buf.put(&b"hello"[..]); * - * assert_eq!(5, buf.len()); - * assert_eq!(buf, b"hello"); + * assert!(!buf.has_remaining_mut()); * ``` - * - * # Panics - * - * This function **may** panic if `cnt > self.remaining_mut()`. - * - * # Implementer notes - * - * It is recommended for implementations of `advance_mut` to panic if - * `cnt > self.remaining_mut()`. If the implementation does not panic, - * the call must behave as if `cnt == self.remaining_mut()`. - * - * A call with `cnt == 0` should never panic and be a no-op. */ -export function advanceMut$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, cnt: rs.usize): void { - rs.bytesMutAdvanceMut(self.v, cnt); +export function hasRemainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self: rs.Place>): boolean { + return remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) > 0; } /** - * Returns a mutable slice starting at the current BufMut position and of - * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the - * whole remainder of the buffer (this allows non-continuous implementation). - * - * This is a lower level function. Most operations are done with other - * functions. + * Returns true if there is space in `self` for more bytes. * - * The returned byte slice may represent uninitialized memory. + * This is equivalent to `self.remaining_mut() != 0`. * * # Examples * * ``` * use bytes::BufMut; * - * let mut buf = Vec::with_capacity(16); - * - * unsafe { - * // MaybeUninit::as_mut_ptr - * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); - * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); - * - * buf.advance_mut(2); + * let mut dst = [0; 5]; + * let mut buf = &mut dst[..]; * - * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); - * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); - * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * assert!(buf.has_remaining_mut()); * - * buf.advance_mut(3); - * } + * buf.put(&b"hello"[..]); * - * assert_eq!(5, buf.len()); - * assert_eq!(buf, b"hello"); + * assert!(!buf.has_remaining_mut()); * ``` - * - * # Implementer notes - * - * This function should never panic. `chunk_mut()` should return an empty - * slice **if and only if** `remaining_mut()` returns 0. In other words, - * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will - * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will - * return an empty slice. - * - * This function may trigger an out-of-memory abort if it tries to allocate - * memory and fails to do so. */ -export function chunkMut$bytes_BufMut_mut_Vec_u8(self: rs.Place): rs.ByteSlice { - return rs.byteVecChunkMut(self.v); +export function hasRemainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place): boolean { + return remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) > 0; } /** - * Returns a mutable slice starting at the current BufMut position and of - * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the - * whole remainder of the buffer (this allows non-continuous implementation). + * Returns true if there is space in `self` for more bytes. * - * This is a lower level function. Most operations are done with other - * functions. - * - * The returned byte slice may represent uninitialized memory. + * This is equivalent to `self.remaining_mut() != 0`. * * # Examples * * ``` * use bytes::BufMut; * - * let mut buf = Vec::with_capacity(16); - * - * unsafe { - * // MaybeUninit::as_mut_ptr - * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); - * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); - * - * buf.advance_mut(2); + * let mut dst = [0; 5]; + * let mut buf = &mut dst[..]; * - * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); - * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); - * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * assert!(buf.has_remaining_mut()); * - * buf.advance_mut(3); - * } + * buf.put(&b"hello"[..]); * - * assert_eq!(5, buf.len()); - * assert_eq!(buf, b"hello"); + * assert!(!buf.has_remaining_mut()); * ``` - * - * # Implementer notes - * - * This function should never panic. `chunk_mut()` should return an empty - * slice **if and only if** `remaining_mut()` returns 0. In other words, - * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will - * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will - * return an empty slice. - * - * This function may trigger an out-of-memory abort if it tries to allocate - * memory and fails to do so. */ -export function chunkMut$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place): rs.ByteSlice { - return rs.bytesMutChunkMut(self.v); +export function hasRemainingMut$bytes_BufMut_mut_mut_slice_u8(self: rs.Place): boolean { + return remainingMut$bytes_BufMut_mut_mut_slice_u8(self) > 0; } /** - * Writes a signed 16 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 2. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -207,23 +114,36 @@ export function chunkMut$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i16): void { - rs.byteVecPutWord(self.v, n, 2, true); +export function put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Pieces(self: rs.Place>, src: Pieces.Pieces): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) < Pieces.remaining$bytes_Buf(src))) { + while (Pieces.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Pieces.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, cnt); + Pieces.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Pieces.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes a signed 16 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 2. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -231,23 +151,36 @@ export function putI16Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_i16_le(0x0809); - * assert_eq!(buf, b"\x09\x08"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putI16Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i16): void { - rs.bytesMutPutWord(self.v, n, 2, true); +export function put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_buf_Provided(self: rs.Place>, src: Provided.Provided): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) < Provided.remaining$bytes_Buf(src))) { + while (Provided.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Provided.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, cnt); + Provided.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Provided.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes a signed 32 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 4. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -255,23 +188,37 @@ export function putI16Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i32): void { - rs.byteVecPutWord(self.v, n, 4, true); +export function put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes(self: rs.Place>, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, cnt); + rs.bytesAdvance(rs.place(() => src, (value) => src = value), cnt); + } + rs.bytesDrop(src); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes a signed 32 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 4. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -279,23 +226,37 @@ export function putI32Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_i32_le(0x0809A0A1); - * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putI32Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i32): void { - rs.bytesMutPutWord(self.v, n, 4, true); +export function put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut(self: rs.Place>, src: rs.BytesMut): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = rs.bytesMutView(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, cnt); + rs.bytesMutAdvance(src, cnt); + } + src[Symbol.dispose](); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes a signed 64 bit integer to `self` in the big-endian byte order. - * - * The current position is advanced by 8. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -303,23 +264,37 @@ export function putI32Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i64): void { - rs.byteVecPutBytes(self.v, rs.i64ToBeBytes(n), false); +export function put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(self: rs.Place>, src: Chain.Chain): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) < Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src))) { + while (Chain.hasRemaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src)) { + const s: rs.ByteSlice = Chain.chunk$bytes_Buf_bytes_Bytes_ref_slice_u8(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, cnt); + Chain.advance$bytes_Buf_bytes_Bytes_ref_slice_u8(src, cnt); + } + lib_drop$bytes_buf_Chain_bytes_Bytes_ref_slice_u8(src); + } else { + panicAdvance({ requested: Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src), available: remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes a signed 64 bit integer to `self` in the big-endian byte order. - * - * The current position is advanced by 8. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -327,23 +302,36 @@ export function putI64$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_i64(0x0102030405060708); - * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putI64$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i64): void { - rs.bytesMutPutBytes(self.v, rs.i64ToBeBytes(n), false); +export function put$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8(self: rs.Place>, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, cnt); + rs.byteSliceAdvance(rs.place(() => src, (value) => src = value), cnt); + } + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes a signed 8 bit integer to `self`. - * - * The current position is advanced by 1. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -351,23 +339,36 @@ export function putI64$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i8): void { - rs.byteVecPutWord(self.v, n, 1, false); +export function put$bytes_BufMut_mut_mut_slice_u8_buf_Pieces(self: rs.Place>, src: Pieces.Pieces): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) < Pieces.remaining$bytes_Buf(src))) { + while (Pieces.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Pieces.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_u8(self, cnt); + Pieces.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Pieces.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) }); + } } /** - * Writes a signed 8 bit integer to `self`. - * - * The current position is advanced by 1. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -375,73 +376,112 @@ export function putI8$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs. * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_i8(0x01); - * assert_eq!(buf, b"\x01"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putI8$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i8): void { - rs.bytesMutPutWord(self.v, n, 1, false); +export function put$bytes_BufMut_mut_mut_slice_u8_buf_Provided(self: rs.Place>, src: Provided.Provided): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) < Provided.remaining$bytes_Buf(src))) { + while (Provided.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Provided.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_u8(self, cnt); + Provided.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Provided.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) }); + } } /** * Transfer bytes into `self` from `src` and advance the cursor by the * number of bytes written. * - * `self` must have enough remaining capacity to contain all of `src`. + * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 6]; + * let mut buf = vec![]; * - * { - * let mut buf = &mut dst[..]; - * buf.put_slice(b"hello"); + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); * - * assert_eq!(1, buf.remaining_mut()); - * } + * assert_eq!(buf, b"hello world"); + * ``` * - * assert_eq!(b"hello\0", &dst); - * ``` + * # Panics + * + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putSlice$bytes_BufMut_mut_Vec_u8(self: rs.Place, src: rs.ByteSlice): void { - rs.byteVecExtendFromSlice(self.v, src); +export function put$bytes_BufMut_mut_mut_slice_u8_bytes_Bytes(self: rs.Place>, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_u8(self, cnt); + rs.bytesAdvance(rs.place(() => src, (value) => src = value), cnt); + } + rs.bytesDrop(src); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) }); + } } /** * Transfer bytes into `self` from `src` and advance the cursor by the * number of bytes written. * - * `self` must have enough remaining capacity to contain all of `src`. + * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 6]; - * - * { - * let mut buf = &mut dst[..]; - * buf.put_slice(b"hello"); + * let mut buf = vec![]; * - * assert_eq!(1, buf.remaining_mut()); - * } + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); * - * assert_eq!(b"hello\0", &dst); + * assert_eq!(buf, b"hello world"); * ``` + * + * # Panics + * + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putSlice$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, src: rs.ByteSlice): void { - rs.bytesMutExtend(self.v, src); +export function put$bytes_BufMut_mut_mut_slice_u8_bytes_BytesMut(self: rs.Place>, src: rs.BytesMut): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = rs.bytesMutView(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_u8(self, cnt); + rs.bytesMutAdvance(src, cnt); + } + src[Symbol.dispose](); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) }); + } } /** - * Writes an unsigned 16 bit integer to `self` in big-endian byte order. - * - * The current position is advanced by 2. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -449,23 +489,37 @@ export function putSlice$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u16): void { - rs.byteVecPutWord(self.v, n, 2, false); +export function put$bytes_BufMut_mut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(self: rs.Place>, src: Chain.Chain): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) < Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src))) { + while (Chain.hasRemaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src)) { + const s: rs.ByteSlice = Chain.chunk$bytes_Buf_bytes_Bytes_ref_slice_u8(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_u8(self, cnt); + Chain.advance$bytes_Buf_bytes_Bytes_ref_slice_u8(src, cnt); + } + lib_drop$bytes_buf_Chain_bytes_Bytes_ref_slice_u8(src); + } else { + panicAdvance({ requested: Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src), available: remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) }); + } } /** - * Writes an unsigned 16 bit integer to `self` in big-endian byte order. - * - * The current position is advanced by 2. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -473,23 +527,36 @@ export function putU16$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u16(0x0809); - * assert_eq!(buf, b"\x08\x09"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putU16$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u16): void { - rs.bytesMutPutWord(self.v, n, 2, false); +export function put$bytes_BufMut_mut_mut_slice_u8_ref_slice_u8(self: rs.Place>, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_mut_slice_u8(self, cnt); + rs.byteSliceAdvance(rs.place(() => src, (value) => src = value), cnt); + } + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) }); + } } /** - * Writes an unsigned 32 bit integer to `self` in big-endian byte order. - * - * The current position is advanced by 4. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -497,23 +564,36 @@ export function putU16$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u32): void { - rs.byteVecPutWord(self.v, n, 4, false); +export function put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Pieces(self: rs.Place, src: Pieces.Pieces): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) < Pieces.remaining$bytes_Buf(src))) { + while (Pieces.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Pieces.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, cnt); + Pieces.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Pieces.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes an unsigned 32 bit integer to `self` in big-endian byte order. - * - * The current position is advanced by 4. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -521,23 +601,36 @@ export function putU32$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u32(0x0809A0A1); - * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putU32$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u32): void { - rs.bytesMutPutWord(self.v, n, 4, false); +export function put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_buf_Provided(self: rs.Place, src: Provided.Provided): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) < Provided.remaining$bytes_Buf(src))) { + while (Provided.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Provided.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, cnt); + Provided.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Provided.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes an unsigned 32 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 4. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -545,23 +638,37 @@ export function putU32$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u32): void { - rs.byteVecPutWord(self.v, n, 4, true); +export function put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_Bytes(self: rs.Place, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, cnt); + rs.bytesAdvance(rs.place(() => src, (value) => src = value), cnt); + } + rs.bytesDrop(src); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes an unsigned 32 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 4. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -569,23 +676,37 @@ export function putU32Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u32_le(0x0809A0A1); - * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putU32Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u32): void { - rs.bytesMutPutWord(self.v, n, 4, true); +export function put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_BytesMut(self: rs.Place, src: rs.BytesMut): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = rs.bytesMutView(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, cnt); + rs.bytesMutAdvance(src, cnt); + } + src[Symbol.dispose](); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes an unsigned 64 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 8. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -593,23 +714,37 @@ export function putU32Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u64): void { - rs.byteVecPutBytes(self.v, rs.u64ToBeBytes(n), true); +export function put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(self: rs.Place, src: Chain.Chain): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) < Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src))) { + while (Chain.hasRemaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src)) { + const s: rs.ByteSlice = Chain.chunk$bytes_Buf_bytes_Bytes_ref_slice_u8(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, cnt); + Chain.advance$bytes_Buf_bytes_Bytes_ref_slice_u8(src, cnt); + } + lib_drop$bytes_buf_Chain_bytes_Bytes_ref_slice_u8(src); + } else { + panicAdvance({ requested: Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src), available: remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes an unsigned 64 bit integer to `self` in little-endian byte order. - * - * The current position is advanced by 8. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -617,23 +752,36 @@ export function putU64Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u64_le(0x0102030405060708); - * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putU64Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u64): void { - rs.bytesMutPutBytes(self.v, rs.u64ToBeBytes(n), true); +export function put$bytes_BufMut_mut_slice_mem_MaybeUninit_u8_ref_slice_u8(self: rs.Place, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, cnt); + rs.byteSliceAdvance(rs.place(() => src, (value) => src = value), cnt); + } + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Writes an unsigned 8 bit integer to `self`. - * - * The current position is advanced by 1. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -641,23 +789,36 @@ export function putU64Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u8): void { - rs.byteVecPutWord(self.v, n, 1, false); +export function put$bytes_BufMut_mut_slice_u8_buf_Pieces(self: rs.Place, src: Pieces.Pieces): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_u8(self) < Pieces.remaining$bytes_Buf(src))) { + while (Pieces.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Pieces.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_u8(self, cnt); + Pieces.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Pieces.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_slice_u8(self) }); + } } /** - * Writes an unsigned 8 bit integer to `self`. - * - * The current position is advanced by 1. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * @@ -665,393 +826,342 @@ export function putU8$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs. * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u8(0x01); - * assert_eq!(buf, b"\x01"); + * + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); + * + * assert_eq!(buf, b"hello world"); * ``` * * # Panics * - * This function panics if there is not enough remaining capacity in - * `self`. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function putU8$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u8): void { - rs.bytesMutPutWord(self.v, n, 1, false); +export function put$bytes_BufMut_mut_slice_u8_buf_Provided(self: rs.Place, src: Provided.Provided): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_u8(self) < Provided.remaining$bytes_Buf(src))) { + while (Provided.hasRemaining$bytes_Buf(src)) { + const s: rs.ByteSlice = Provided.chunk$bytes_Buf(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_u8(self, cnt); + Provided.advance$bytes_Buf(src, cnt); + } + } else { + panicAdvance({ requested: Provided.remaining$bytes_Buf(src), available: remainingMut$bytes_BufMut_mut_mut_slice_u8(self) }); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. - * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; + * let mut buf = vec![]; * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * assert_eq!(buf, b"hello world"); * ``` * - * # Implementer notes - * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. - * - * # Note + * # Panics * - * `remaining_mut` may return value smaller than actual available space. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function remainingMut$bytes_BufMut_mut_Vec_u8(self: rs.ByteVec): rs.usize { - return 0x7fffffff - self.length as rs.usize; +export function put$bytes_BufMut_mut_slice_u8_bytes_Bytes(self: rs.Place, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_u8(self, cnt); + rs.bytesAdvance(rs.place(() => src, (value) => src = value), cnt); + } + rs.bytesDrop(src); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_slice_u8(self) }); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. - * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; + * let mut buf = vec![]; * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * assert_eq!(buf, b"hello world"); * ``` * - * # Implementer notes - * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. - * - * # Note + * # Panics * - * `remaining_mut` may return value smaller than actual available space. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function remainingMut$bytes_BufMut_mut_boxed_Box_Vec_u8(self: rs.Place): rs.usize { - return remainingMut$bytes_BufMut_boxed_Box_Vec_u8(self.v); +export function put$bytes_BufMut_mut_slice_u8_bytes_BytesMut(self: rs.Place, src: rs.BytesMut): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = rs.bytesMutView(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_u8(self, cnt); + rs.bytesMutAdvance(src, cnt); + } + src[Symbol.dispose](); + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_slice_u8(self) }); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. - * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; + * let mut buf = vec![]; * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * assert_eq!(buf, b"hello world"); * ``` * - * # Implementer notes - * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. - * - * # Note + * # Panics * - * `remaining_mut` may return value smaller than actual available space. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function remainingMut$bytes_BufMut_mut_boxed_Box_bytes_BytesMut(self: rs.Place): rs.usize { - return remainingMut$bytes_BufMut_boxed_Box_bytes_BytesMut(self.v); +export function put$bytes_BufMut_mut_slice_u8_bytes_buf_Chain_bytes_Bytes_ref_slice_u8(self: rs.Place, src: Chain.Chain): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_u8(self) < Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src))) { + while (Chain.hasRemaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src)) { + const s: rs.ByteSlice = Chain.chunk$bytes_Buf_bytes_Bytes_ref_slice_u8(src); + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_u8(self, cnt); + Chain.advance$bytes_Buf_bytes_Bytes_ref_slice_u8(src, cnt); + } + lib_drop$bytes_buf_Chain_bytes_Bytes_ref_slice_u8(src); + } else { + panicAdvance({ requested: Chain.remaining$bytes_Buf_bytes_Bytes_ref_slice_u8(src), available: remainingMut$bytes_BufMut_mut_mut_slice_u8(self) }); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. - * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; + * let mut buf = vec![]; * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * buf.put_u8(b'h'); + * buf.put(&b"ello"[..]); + * buf.put(&b" world"[..]); * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * assert_eq!(buf, b"hello world"); * ``` * - * # Implementer notes + * # Panics * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. - * - * # Note - * - * `remaining_mut` may return value smaller than actual available space. + * Panics if `self` does not have enough capacity to contain `src`. */ -export function remainingMut$bytes_BufMut_mut_boxed_Box_mut_bytes_BytesMut(self: rs.Place): rs.usize { - return remainingMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self.v); +export function put$bytes_BufMut_mut_slice_u8_ref_slice_u8(self: rs.Place, src: rs.ByteSlice): void { + if (!(remainingMut$bytes_BufMut_mut_mut_slice_u8(self) < src.length)) { + while (src.length !== 0) { + const s: rs.ByteSlice = src; + const d: rs.ByteSlice = chunkMut$bytes_BufMut_mut_slice_u8(self); + const cnt: rs.usize = rs.min(s.length, UninitSlice.len(d)); + UninitSlice.copyFromSlice(UninitSlice.indexMut$ops_IndexMut_ops_RangeTo_usize(d, { end: cnt }, { file: "/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bytes-1.12.1/src/buf/buf_mut.rs", line: 218, col: 14 }), rs.byteSliceRange(s, 0, cnt)); + advanceMut$bytes_BufMut_mut_slice_u8(self, cnt); + rs.byteSliceAdvance(rs.place(() => src, (value) => src = value), cnt); + } + } else { + panicAdvance({ requested: src.length, available: remainingMut$bytes_BufMut_mut_mut_slice_u8(self) }); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. + * Put `cnt` bytes `val` into `self`. * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * Logically equivalent to calling `self.put_u8(val)` `cnt` times, but may work faster. * - * # Examples + * `self` must have at least `cnt` remaining capacity. * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; - * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * let mut dst = [0; 6]; * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); - * ``` + * { + * let mut buf = &mut dst[..]; + * buf.put_bytes(b'a', 4); * - * # Implementer notes + * assert_eq!(2, buf.remaining_mut()); + * } * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. + * assert_eq!(b"aaaa\0\0", &dst); + * ``` * - * # Note + * # Panics * - * `remaining_mut` may return value smaller than actual available space. + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function remainingMut$bytes_BufMut_mut_bytes_BytesMut(self: rs.BytesMut): rs.usize { - return 0x7fffffff - self.length as rs.usize; +export function putBytes$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, val: rs.u8, cnt: rs.usize): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) < cnt)) { + while (cnt > 0) { + const dst: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); + const dstLen: rs.usize = rs.min(UninitSlice.len(dst), cnt); + rs.ptrWriteBytes(UninitSlice.asMutPtr(dst), val, dstLen); + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, dstLen); + cnt = rs.usizeSub(cnt, dstLen); + } + } else { + panicAdvance({ requested: cnt, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self) }); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. + * Put `cnt` bytes `val` into `self`. * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * Logically equivalent to calling `self.put_u8(val)` `cnt` times, but may work faster. * - * # Examples + * `self` must have at least `cnt` remaining capacity. * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; - * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * let mut dst = [0; 6]; * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); - * ``` + * { + * let mut buf = &mut dst[..]; + * buf.put_bytes(b'a', 4); * - * # Implementer notes + * assert_eq!(2, buf.remaining_mut()); + * } * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. + * assert_eq!(b"aaaa\0\0", &dst); + * ``` * - * # Note + * # Panics * - * `remaining_mut` may return value smaller than actual available space. + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function remainingMut$bytes_BufMut_mut_mut_Vec_u8(self: rs.Place): rs.usize { - return remainingMut$bytes_BufMut_mut_Vec_u8(self.v); +export function putBytes$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, val: rs.u8, cnt: rs.usize): void { + if (!(remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) < cnt)) { + while (cnt > 0) { + const dst: rs.ByteSlice = chunkMut$bytes_BufMut_mut_mut_slice_u8(self); + const dstLen: rs.usize = rs.min(UninitSlice.len(dst), cnt); + rs.ptrWriteBytes(UninitSlice.asMutPtr(dst), val, dstLen); + advanceMut$bytes_BufMut_mut_mut_slice_u8(self, dstLen); + cnt = rs.usizeSub(cnt, dstLen); + } + } else { + panicAdvance({ requested: cnt, available: remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self) }); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. + * Writes an unsigned 8 bit integer to `self`. * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * The current position is advanced by 1. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; - * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); - * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); * ``` * - * # Implementer notes - * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. - * - * # Note + * # Panics * - * `remaining_mut` may return value smaller than actual available space. + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function remainingMut$bytes_BufMut_mut_mut_bytes_BytesMut(self: rs.Place): rs.usize { - return remainingMut$bytes_BufMut_mut_bytes_BytesMut(self.v); +export function putU8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u8): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(Uint8Array.of(n))); } /** - * Advance the internal cursor of the BufMut - * - * The next call to `chunk_mut` will return a slice starting `cnt` bytes - * further into the underlying buffer. - * - * # Safety + * Writes an unsigned 8 bit integer to `self`. * - * The caller must ensure that the next `cnt` bytes of `chunk` are - * initialized. + * The current position is advanced by 1. * * # Examples * * ``` * use bytes::BufMut; * - * let mut buf = Vec::with_capacity(16); - * - * // Write some data - * buf.chunk_mut()[0..2].copy_from_slice(b"he"); - * unsafe { buf.advance_mut(2) }; - * - * // write more bytes - * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); - * - * unsafe { buf.advance_mut(3); } - * - * assert_eq!(5, buf.len()); - * assert_eq!(buf, b"hello"); + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); * ``` * * # Panics * - * This function **may** panic if `cnt > self.remaining_mut()`. - * - * # Implementer notes - * - * It is recommended for implementations of `advance_mut` to panic if - * `cnt > self.remaining_mut()`. If the implementation does not panic, - * the call must behave as if `cnt == self.remaining_mut()`. - * - * A call with `cnt == 0` should never panic and be a no-op. + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function advanceMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Place, cnt: rs.usize): void { - advanceMut$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value), cnt); +export function putU8$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u8): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(Uint8Array.of(n))); } /** - * Returns a mutable slice starting at the current BufMut position and of - * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the - * whole remainder of the buffer (this allows non-continuous implementation). - * - * This is a lower level function. Most operations are done with other - * functions. + * Writes a signed 8 bit integer to `self`. * - * The returned byte slice may represent uninitialized memory. + * The current position is advanced by 1. * * # Examples * * ``` * use bytes::BufMut; * - * let mut buf = Vec::with_capacity(16); - * - * unsafe { - * // MaybeUninit::as_mut_ptr - * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); - * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); - * - * buf.advance_mut(2); - * - * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); - * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); - * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); - * - * buf.advance_mut(3); - * } - * - * assert_eq!(5, buf.len()); - * assert_eq!(buf, b"hello"); + * let mut buf = vec![]; + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); * ``` * - * # Implementer notes - * - * This function should never panic. `chunk_mut()` should return an empty - * slice **if and only if** `remaining_mut()` returns 0. In other words, - * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will - * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will - * return an empty slice. + * # Panics * - * This function may trigger an out-of-memory abort if it tries to allocate - * memory and fails to do so. + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function chunkMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Place): rs.ByteSlice { - return chunkMut$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value)); +export function putI8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.i8): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(Uint8Array.of(n & 0xff))); } /** - * Writes a signed 16 bit integer to `self` in little-endian byte order. + * Writes a signed 8 bit integer to `self`. * - * The current position is advanced by 2. + * The current position is advanced by 1. * * # Examples * @@ -1059,8 +1169,8 @@ export function chunkMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Plac * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_i16_le(0x0809); - * assert_eq!(buf, b"\x09\x08"); + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); * ``` * * # Panics @@ -1068,12 +1178,12 @@ export function chunkMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Plac * This function panics if there is not enough remaining capacity in * `self`. */ -export function putI16Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.i16): void { - rs.byteVecPutWord(self.v, n, 2, true); +export function putI8$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.i8): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(Uint8Array.of(n & 0xff))); } /** - * Writes a signed 16 bit integer to `self` in little-endian byte order. + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. * * The current position is advanced by 2. * @@ -1083,8 +1193,8 @@ export function putI16Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.i16): void { - rs.bytesMutPutWord(self.v, n, 2, true); +export function putU16$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u16): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.u16ToBeBytes(n))); } /** - * Writes a signed 32 bit integer to `self` in little-endian byte order. + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. * - * The current position is advanced by 4. + * The current position is advanced by 2. * * # Examples * @@ -1107,8 +1217,8 @@ export function putI16Le$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i32): void { - rs.byteVecPutWord(self.v, n, 4, true); +export function putU16$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u16): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.u16ToBeBytes(n))); } /** - * Writes a signed 32 bit integer to `self` in little-endian byte order. + * Writes a signed 16 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 4. + * The current position is advanced by 2. * * # Examples * @@ -1131,8 +1241,8 @@ export function putI32Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.i32): void { - rs.bytesMutPutWord(self.v, n, 4, true); +export function putI16Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.i16): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.i16ToBeBytes(n).reverse())); } /** - * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * Writes a signed 16 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 8. + * The current position is advanced by 2. * * # Examples * @@ -1155,8 +1265,8 @@ export function putI32Le$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i64): void { - rs.byteVecPutBytes(self.v, rs.i64ToBeBytes(n), false); +export function putI16Le$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.i16): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.i16ToBeBytes(n).reverse())); } /** - * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. * - * The current position is advanced by 8. + * The current position is advanced by 4. * * # Examples * @@ -1179,8 +1289,8 @@ export function putI64$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_i64(0x0102030405060708); - * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * buf.put_u32(0x0809A0A1); + * assert_eq!(buf, b"\x08\x09\xA0\xA1"); * ``` * * # Panics @@ -1188,14 +1298,14 @@ export function putI64$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * This function panics if there is not enough remaining capacity in * `self`. */ -export function putI64$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i64): void { - rs.bytesMutPutBytes(self.v, rs.i64ToBeBytes(n), false); +export function putU32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u32): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.u32ToBeBytes(n))); } /** - * Writes a signed 8 bit integer to `self`. + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. * - * The current position is advanced by 1. + * The current position is advanced by 4. * * # Examples * @@ -1203,8 +1313,8 @@ export function putI64$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i8): void { - rs.byteVecPutWord(self.v, n, 1, false); +export function putU32$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u32): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.u32ToBeBytes(n))); } /** - * Writes a signed 8 bit integer to `self`. + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 1. + * The current position is advanced by 4. * * # Examples * @@ -1227,8 +1337,8 @@ export function putI8$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_i8(0x01); - * assert_eq!(buf, b"\x01"); + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); * ``` * * # Panics @@ -1236,89 +1346,86 @@ export function putI8$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * This function panics if there is not enough remaining capacity in * `self`. */ -export function putI8$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i8): void { - rs.bytesMutPutWord(self.v, n, 1, false); +export function putU32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u32): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.u32ToBeBytes(n).reverse())); } /** - * Transfer bytes into `self` from `src` and advance the cursor by the - * number of bytes written. + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. * - * `self` must have enough remaining capacity to contain all of `src`. + * The current position is advanced by 4. + * + * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 6]; - * - * { - * let mut buf = &mut dst[..]; - * buf.put_slice(b"hello"); + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` * - * assert_eq!(1, buf.remaining_mut()); - * } + * # Panics * - * assert_eq!(b"hello\0", &dst); - * ``` + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function putSlice$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, src: rs.ByteSlice): void { - rs.byteVecExtendFromSlice(self.v, src); +export function putU32Le$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u32): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.u32ToBeBytes(n).reverse())); } /** - * Transfer bytes into `self` from `src` and advance the cursor by the - * number of bytes written. + * Writes a signed 32 bit integer to `self` in little-endian byte order. * - * `self` must have enough remaining capacity to contain all of `src`. + * The current position is advanced by 4. + * + * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 6]; - * - * { - * let mut buf = &mut dst[..]; - * buf.put_slice(b"hello"); + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` * - * assert_eq!(1, buf.remaining_mut()); - * } + * # Panics * - * assert_eq!(b"hello\0", &dst); - * ``` + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function putSlice$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, src: rs.ByteSlice): void { - rs.bytesMutExtend(self.v, src); +export function putI32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.i32): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.i32ToBeBytes(n).reverse())); } /** - * Transfer bytes into `self` from `src` and advance the cursor by the - * number of bytes written. + * Writes a signed 32 bit integer to `self` in little-endian byte order. * - * `self` must have enough remaining capacity to contain all of `src`. + * The current position is advanced by 4. + * + * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 6]; - * - * { - * let mut buf = &mut dst[..]; - * buf.put_slice(b"hello"); + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` * - * assert_eq!(1, buf.remaining_mut()); - * } + * # Panics * - * assert_eq!(b"hello\0", &dst); - * ``` + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function putSlice$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Place, src: rs.ByteSlice): void { - putSlice$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value), src); +export function putI32Le$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.i32): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.i32ToBeBytes(n).reverse())); } /** - * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * Writes an unsigned 64 bit integer to `self` in the big-endian byte order. * - * The current position is advanced by 2. + * The current position is advanced by 8. * * # Examples * @@ -1326,8 +1433,8 @@ export function putSlice$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Plac * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u16(0x0809); - * assert_eq!(buf, b"\x08\x09"); + * buf.put_u64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); * ``` * * # Panics @@ -1335,14 +1442,14 @@ export function putSlice$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Plac * This function panics if there is not enough remaining capacity in * `self`. */ -export function putU16$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.u16): void { - rs.byteVecPutWord(self.v, n, 2, false); +export function putU64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u64): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.u64ToBeBytes(n))); } /** - * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * Writes an unsigned 64 bit integer to `self` in the big-endian byte order. * - * The current position is advanced by 2. + * The current position is advanced by 8. * * # Examples * @@ -1350,8 +1457,8 @@ export function putU16$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u16(0x0809); - * assert_eq!(buf, b"\x08\x09"); + * buf.put_u64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); * ``` * * # Panics @@ -1359,14 +1466,14 @@ export function putU16$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * This function panics if there is not enough remaining capacity in * `self`. */ -export function putU16$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u16): void { - rs.bytesMutPutWord(self.v, n, 2, false); +export function putU64$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u64): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.u64ToBeBytes(n))); } /** - * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 4. + * The current position is advanced by 8. * * # Examples * @@ -1374,8 +1481,8 @@ export function putU16$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u32): void { - rs.byteVecPutWord(self.v, n, 4, false); +export function putU64Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u64): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.u64ToBeBytes(n).reverse())); } /** - * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 4. + * The current position is advanced by 8. * * # Examples * @@ -1398,8 +1505,8 @@ export function putU32$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u32(0x0809A0A1); - * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * buf.put_u64_le(0x0102030405060708); + * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); * ``` * * # Panics @@ -1407,14 +1514,14 @@ export function putU32$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * This function panics if there is not enough remaining capacity in * `self`. */ -export function putU32$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u32): void { - rs.bytesMutPutWord(self.v, n, 4, false); +export function putU64Le$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u64): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.u64ToBeBytes(n).reverse())); } /** - * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * Writes a signed 64 bit integer to `self` in the big-endian byte order. * - * The current position is advanced by 4. + * The current position is advanced by 8. * * # Examples * @@ -1422,8 +1529,8 @@ export function putU32$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u32): void { - putU32Le$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value), n); +export function putI64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.i64): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.i64ToBeBytes(n))); } /** - * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * Writes a signed 64 bit integer to `self` in the big-endian byte order. * * The current position is advanced by 8. * @@ -1446,8 +1553,8 @@ export function putU32Le$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Plac * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u64_le(0x0102030405060708); - * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * buf.put_i64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); * ``` * * # Panics @@ -1455,14 +1562,14 @@ export function putU32Le$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Plac * This function panics if there is not enough remaining capacity in * `self`. */ -export function putU64Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.u64): void { - rs.byteVecPutBytes(self.v, rs.u64ToBeBytes(n), true); +export function putI64$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.i64): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.i64ToBeBytes(n))); } /** - * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * Writes an unsigned 128 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 8. + * The current position is advanced by 16. * * # Examples * @@ -1470,8 +1577,8 @@ export function putU64Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.u64): void { - rs.bytesMutPutBytes(self.v, rs.u64ToBeBytes(n), true); +export function putU128Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u128): void { + putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.u128ToBeBytes(n).reverse())); } /** - * Writes an unsigned 8 bit integer to `self`. + * Writes an unsigned 128 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 1. + * The current position is advanced by 16. * * # Examples * @@ -1494,8 +1601,8 @@ export function putU64Le$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u8): void { - rs.byteVecPutWord(self.v, n, 1, false); +export function putU128Le$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u128): void { + putSlice$bytes_BufMut_mut_mut_slice_u8(self, rs.byteSliceFrom(rs.u128ToBeBytes(n).reverse())); } /** - * Writes an unsigned 8 bit integer to `self`. + * Writes an unsigned 128 bit integer to `self` in little-endian byte order. * - * The current position is advanced by 1. + * The current position is advanced by 16. * * # Examples * @@ -1518,8 +1625,8 @@ export function putU8$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * use bytes::BufMut; * * let mut buf = vec![]; - * buf.put_u8(0x01); - * assert_eq!(buf, b"\x01"); + * buf.put_u128_le(0x01020304050607080910111213141516); + * assert_eq!(buf, b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01"); * ``` * * # Panics @@ -1527,125 +1634,4094 @@ export function putU8$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, * This function panics if there is not enough remaining capacity in * `self`. */ -export function putU8$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u8): void { - rs.bytesMutPutWord(self.v, n, 1, false); +export function putU128Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u128): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceFrom(rs.u128ToBeBytes(n).reverse())); } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. + * Writes an unsigned 128 bit integer to `self` in little-endian byte order. * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * The current position is advanced by 16. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; - * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); - * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * let mut buf = vec![]; + * buf.put_u128_le(0x01020304050607080910111213141516); + * assert_eq!(buf, b"\x16\x15\x14\x13\x12\x11\x10\x09\x08\x07\x06\x05\x04\x03\x02\x01"); * ``` * - * # Implementer notes - * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. - * - * # Note + * # Panics * - * `remaining_mut` may return value smaller than actual available space. + * This function panics if there is not enough remaining capacity in + * `self`. */ -export function remainingMut$bytes_BufMut_boxed_Box_Vec_u8(self: rs.ByteVec): rs.usize { - return 0x7fffffff - self.length as rs.usize; +export function putU128Le$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u128): void { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceFrom(rs.u128ToBeBytes(n).reverse())); } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. + * Writes an unsigned n-byte integer to `self` in big-endian byte order. * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. - * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * The current position is advanced by `nbytes`. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; + * let mut buf = vec![]; + * buf.put_uint(0x010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * # Panics * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); - * ``` + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putUint$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.u64ToBeBytes(n)), _4)); + } +} + +/** + * Writes an unsigned n-byte integer to `self` in big-endian byte order. * - * # Implementer notes + * The current position is advanced by `nbytes`. * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. + * # Examples * - * # Note + * ``` + * use bytes::BufMut; * - * `remaining_mut` may return value smaller than actual available space. + * let mut buf = vec![]; + * buf.put_uint(0x010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. */ -export function remainingMut$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.BytesMut): rs.usize { - return 0x7fffffff - self.length as rs.usize; +export function putUint$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_mut_slice_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.u64ToBeBytes(n)), _4)); + } } /** - * Returns the number of bytes that can be written from the current - * position until the end of the buffer is reached. - * - * This value is greater than or equal to the length of the slice returned - * by `chunk_mut()`. + * Writes an unsigned n-byte integer to `self` in big-endian byte order. * - * Writing to a `BufMut` may involve allocating more memory on the fly. - * Implementations may fail before reaching the number of bytes indicated - * by this method if they encounter an allocation failure. + * The current position is advanced by `nbytes`. * * # Examples * * ``` * use bytes::BufMut; * - * let mut dst = [0; 10]; - * let mut buf = &mut dst[..]; + * let mut buf = vec![]; + * buf.put_uint(0x010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` * - * let original_remaining = buf.remaining_mut(); - * buf.put(&b"hello"[..]); + * # Panics * - * assert_eq!(original_remaining - 5, buf.remaining_mut()); - * ``` + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putUint$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.u64ToBeBytes(n)), _4)); + } +} + +/** + * Writes an unsigned n-byte integer to `self` in big-endian byte order. * - * # Implementer notes + * The current position is advanced by `nbytes`. * - * Implementations of `remaining_mut` should ensure that the return value - * does not change unless a call is made to `advance_mut` or any other - * function that is documented to change the `BufMut`'s current position. + * # Examples * - * # Note + * ``` + * use bytes::BufMut; * - * `remaining_mut` may return value smaller than actual available space. + * let mut buf = vec![]; + * buf.put_uint(0x010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putUint$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.u64ToBeBytes(n)), _4)); + } +} + +/** + * Writes an unsigned n-byte integer to `self` in the little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_uint_le(0x010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putUintLe$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.u64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, _5); + } +} + +/** + * Writes an unsigned n-byte integer to `self` in the little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_uint_le(0x010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putUintLe$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.u64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_mut_slice_u8(self, _5); + } +} + +/** + * Writes an unsigned n-byte integer to `self` in the little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_uint_le(0x010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putUintLe$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.u64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.u64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, _5); + } +} + +/** + * Writes an unsigned n-byte integer to `self` in the little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_uint_le(0x010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putUintLe$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.u64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.u64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_slice_u8(self, _5); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in big-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int(0x0504010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putInt$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.i64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.i64ToBeBytes(n)), _4)); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in big-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int(0x0504010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putInt$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.i64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_mut_slice_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.i64ToBeBytes(n)), _4)); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in big-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int(0x0504010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putInt$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.i64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.i64ToBeBytes(n)), _4)); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in big-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int(0x0504010203, 3); + * assert_eq!(buf, b"\x01\x02\x03"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putInt$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.i64, nbytes: rs.usize): void { + const _4: rs.usize | undefined = rs.usizeCheckedSub(8, nbytes); + if (_4 === undefined) { + panicDoesNotFit(nbytes, 8); + } else { + putSlice$bytes_BufMut_mut_slice_u8(self, rs.byteSliceRange(rs.byteSliceFrom(rs.i64ToBeBytes(n)), _4)); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int_le(0x0504010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putIntLe$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.i64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.i64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, _5); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int_le(0x0504010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putIntLe$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.i64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.i64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_mut_slice_u8(self, _5); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int_le(0x0504010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putIntLe$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.i64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.i64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, _5); + } +} + +/** + * Writes low `nbytes` of a signed integer to `self` in little-endian byte order. + * + * The current position is advanced by `nbytes`. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_int_le(0x0504010203, 3); + * assert_eq!(buf, b"\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self` or if `nbytes` is greater than 8. + */ +export function putIntLe$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.i64, nbytes: rs.usize): void { + const slice: Uint8Array = rs.i64ToBeBytes(n).reverse(); + const _5: rs.ByteSlice | undefined = rs.byteSliceGetRange(rs.byteSliceFrom(slice), 0, nbytes); + if (_5 === undefined) { + panicDoesNotFit(nbytes, rs.byteSliceFrom(slice).length); + } else { + putSlice$bytes_BufMut_mut_slice_u8(self, _5); + } +} + +/** + * Writes an IEEE754 single-precision (4 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f32(1.2f32); + * assert_eq!(buf, b"\x3F\x99\x99\x9A"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF32$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.f32): void { + putU32$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, rs.f32ToBits(n)); +} + +/** + * Writes an IEEE754 single-precision (4 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f32(1.2f32); + * assert_eq!(buf, b"\x3F\x99\x99\x9A"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF32$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.f32): void { + putU32$bytes_BufMut_mut_mut_slice_u8(self, rs.f32ToBits(n)); +} + +/** + * Writes an IEEE754 single-precision (4 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f32(1.2f32); + * assert_eq!(buf, b"\x3F\x99\x99\x9A"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.f32): void { + putU32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.f32ToBits(n)); +} + +/** + * Writes an IEEE754 single-precision (4 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f32(1.2f32); + * assert_eq!(buf, b"\x3F\x99\x99\x9A"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF32$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.f32): void { + putU32$bytes_BufMut_mut_slice_u8(self, rs.f32ToBits(n)); +} + +/** + * Writes an IEEE754 double-precision (8 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f64(1.2f64); + * assert_eq!(buf, b"\x3F\xF3\x33\x33\x33\x33\x33\x33"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.f64): void { + putU64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self, rs.f64ToBits(n)); +} + +/** + * Writes an IEEE754 double-precision (8 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f64(1.2f64); + * assert_eq!(buf, b"\x3F\xF3\x33\x33\x33\x33\x33\x33"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF64$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.f64): void { + putU64$bytes_BufMut_mut_mut_slice_u8(self, rs.f64ToBits(n)); +} + +/** + * Writes an IEEE754 double-precision (8 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f64(1.2f64); + * assert_eq!(buf, b"\x3F\xF3\x33\x33\x33\x33\x33\x33"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, n: rs.f64): void { + putU64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, rs.f64ToBits(n)); +} + +/** + * Writes an IEEE754 double-precision (8 bytes) floating point number to + * `self` in big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_f64(1.2f64); + * assert_eq!(buf, b"\x3F\xF3\x33\x33\x33\x33\x33\x33"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putF64$bytes_BufMut_mut_slice_u8(self: rs.Place, n: rs.f64): void { + putU64$bytes_BufMut_mut_slice_u8(self, rs.f64ToBits(n)); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_mut_Vec_u8(self: rs.Place, cnt: rs.usize): void { + rs.byteVecAdvanceMut(self.v, cnt); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, cnt: rs.usize): void { + rs.bytesMutAdvanceMut(self.v, cnt); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, cnt: rs.usize): void { + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, cnt); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, cnt: rs.usize): void { + advanceMut$bytes_BufMut_mut_slice_u8(self.v, cnt); +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_mut_Vec_u8(self: rs.Place): rs.ByteSlice { + return rs.byteVecChunkMut(self.v); +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place): rs.ByteSlice { + return rs.bytesMutChunkMut(self.v); +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>): rs.ByteSlice { + return chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v); +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>): rs.ByteSlice { + return chunkMut$bytes_BufMut_mut_slice_u8(self.v); +} + +/** + * Writes a signed 16 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i16_le(0x0809); + * assert_eq!(buf, b"\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI16Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.i16): void { + rs.byteVecPutWord(self.v, n, 2, true); +} + +/** + * Writes a signed 16 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i16_le(0x0809); + * assert_eq!(buf, b"\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI16Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i16): void { + rs.bytesMutPutWord(self.v, n, 2, true); +} + +/** + * Writes a signed 16 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i16_le(0x0809); + * assert_eq!(buf, b"\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI16Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.i16): void { + putI16Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes a signed 16 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i16_le(0x0809); + * assert_eq!(buf, b"\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI16Le$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.i16): void { + putI16Le$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes a signed 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI32Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.i32): void { + rs.byteVecPutWord(self.v, n, 4, true); +} + +/** + * Writes a signed 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI32Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i32): void { + rs.bytesMutPutWord(self.v, n, 4, true); +} + +/** + * Writes a signed 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI32Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.i32): void { + putI32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes a signed 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI32Le$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.i32): void { + putI32Le$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI64$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.i64): void { + rs.byteVecPutBytes(self.v, rs.i64ToBeBytes(n), false); +} + +/** + * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI64$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i64): void { + rs.bytesMutPutBytes(self.v, rs.i64ToBeBytes(n), false); +} + +/** + * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.i64): void { + putI64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI64$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.i64): void { + putI64$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes a signed 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI8$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.i8): void { + rs.byteVecPutWord(self.v, n, 1, false); +} + +/** + * Writes a signed 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI8$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.i8): void { + rs.bytesMutPutWord(self.v, n, 1, false); +} + +/** + * Writes a signed 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI8$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.i8): void { + putI8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes a signed 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI8$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.i8): void { + putI8$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_mut_Vec_u8(self: rs.Place, src: rs.ByteSlice): void { + rs.byteVecExtendFromSlice(self.v, src); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, src: rs.ByteSlice): void { + rs.bytesMutExtend(self.v, src); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, src: rs.ByteSlice): void { + putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, src); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, src: rs.ByteSlice): void { + putSlice$bytes_BufMut_mut_slice_u8(self.v, src); +} + +/** + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u16(0x0809); + * assert_eq!(buf, b"\x08\x09"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU16$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.u16): void { + rs.byteVecPutWord(self.v, n, 2, false); +} + +/** + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u16(0x0809); + * assert_eq!(buf, b"\x08\x09"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU16$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u16): void { + rs.bytesMutPutWord(self.v, n, 2, false); +} + +/** + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u16(0x0809); + * assert_eq!(buf, b"\x08\x09"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU16$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u16): void { + putU16$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u16(0x0809); + * assert_eq!(buf, b"\x08\x09"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU16$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u16): void { + putU16$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32(0x0809A0A1); + * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.u32): void { + rs.byteVecPutWord(self.v, n, 4, false); +} + +/** + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32(0x0809A0A1); + * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u32): void { + rs.bytesMutPutWord(self.v, n, 4, false); +} + +/** + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32(0x0809A0A1); + * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u32): void { + putU32$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32(0x0809A0A1); + * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u32): void { + putU32$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.u32): void { + rs.byteVecPutWord(self.v, n, 4, true); +} + +/** + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u32): void { + rs.bytesMutPutWord(self.v, n, 4, true); +} + +/** + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u32): void { + putU32Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32Le$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u32): void { + putU32Le$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes an unsigned 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u64): void { + putU64$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes an unsigned 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u64): void { + putU64$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64_le(0x0102030405060708); + * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64Le$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.u64): void { + rs.byteVecPutBytes(self.v, rs.u64ToBeBytes(n), true); +} + +/** + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64_le(0x0102030405060708); + * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64Le$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u64): void { + rs.bytesMutPutBytes(self.v, rs.u64ToBeBytes(n), true); +} + +/** + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64_le(0x0102030405060708); + * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u64): void { + putU64Le$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64_le(0x0102030405060708); + * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64Le$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u64): void { + putU64Le$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Writes an unsigned 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU8$bytes_BufMut_mut_Vec_u8(self: rs.Place, n: rs.u8): void { + rs.byteVecPutWord(self.v, n, 1, false); +} + +/** + * Writes an unsigned 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU8$bytes_BufMut_mut_bytes_BytesMut(self: rs.Place, n: rs.u8): void { + rs.bytesMutPutWord(self.v, n, 1, false); +} + +/** + * Writes an unsigned 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU8$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u8): void { + putU8$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v, n); +} + +/** + * Writes an unsigned 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU8$bytes_BufMut_mut_mut_slice_u8(self: rs.Place>, n: rs.u8): void { + putU8$bytes_BufMut_mut_slice_u8(self.v, n); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_Vec_u8(self: rs.ByteVec): rs.usize { + return 0x7fffffff - self.length as rs.usize; +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_boxed_Box_Vec_u8(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_boxed_Box_Vec_u8(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_boxed_Box_bytes_BytesMut(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_boxed_Box_bytes_BytesMut(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_boxed_Box_mut_bytes_BytesMut(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>): rs.usize { + return remainingMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_boxed_Box_mut_mut_slice_u8(self: rs.Place>): rs.usize { + return remainingMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_bytes_BytesMut(self: rs.BytesMut): rs.usize { + return 0x7fffffff - self.length as rs.usize; +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_mut_Vec_u8(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_mut_Vec_u8(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_mut_bytes_BytesMut(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_mut_bytes_BytesMut(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>): rs.usize { + return remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_mut_mut_slice_u8(self: rs.Place>): rs.usize { + return remainingMut$bytes_BufMut_mut_mut_slice_u8(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self.v); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_mut_slice_u8(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_mut_slice_u8(self.v); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Place, cnt: rs.usize): void { + advanceMut$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value), cnt); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, cnt: rs.usize): void { + advanceMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(rs.place(() => self.v, (value) => self.v = value), cnt); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8(self: rs.Place>, cnt: rs.usize): void { + advanceMut$bytes_BufMut_mut_mut_slice_u8(rs.place(() => self.v, (value) => self.v = value), cnt); +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Place): rs.ByteSlice { + return chunkMut$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value)); +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>): rs.ByteSlice { + return chunkMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(rs.place(() => self.v, (value) => self.v = value)); +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8(self: rs.Place>): rs.ByteSlice { + return chunkMut$bytes_BufMut_mut_mut_slice_u8(rs.place(() => self.v, (value) => self.v = value)); +} + +/** + * Writes a signed 16 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i16_le(0x0809); + * assert_eq!(buf, b"\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI16Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.i16): void { + rs.byteVecPutWord(self.v, n, 2, true); +} + +/** + * Writes a signed 16 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i16_le(0x0809); + * assert_eq!(buf, b"\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI16Le$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i16): void { + rs.bytesMutPutWord(self.v, n, 2, true); +} + +/** + * Writes a signed 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI32Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.i32): void { + rs.byteVecPutWord(self.v, n, 4, true); +} + +/** + * Writes a signed 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI32Le$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i32): void { + rs.bytesMutPutWord(self.v, n, 4, true); +} + +/** + * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI64$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.i64): void { + rs.byteVecPutBytes(self.v, rs.i64ToBeBytes(n), false); +} + +/** + * Writes a signed 64 bit integer to `self` in the big-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i64(0x0102030405060708); + * assert_eq!(buf, b"\x01\x02\x03\x04\x05\x06\x07\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI64$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i64): void { + rs.bytesMutPutBytes(self.v, rs.i64ToBeBytes(n), false); +} + +/** + * Writes a signed 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI8$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.i8): void { + rs.byteVecPutWord(self.v, n, 1, false); +} + +/** + * Writes a signed 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_i8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putI8$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.i8): void { + rs.bytesMutPutWord(self.v, n, 1, false); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, src: rs.ByteSlice): void { + rs.byteVecExtendFromSlice(self.v, src); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, src: rs.ByteSlice): void { + rs.bytesMutExtend(self.v, src); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Place, src: rs.ByteSlice): void { + putSlice$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value), src); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, src: rs.ByteSlice): void { + putSlice$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(rs.place(() => self.v, (value) => self.v = value), src); +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_boxed_Box_mut_mut_slice_u8(self: rs.Place>, src: rs.ByteSlice): void { + putSlice$bytes_BufMut_mut_mut_slice_u8(rs.place(() => self.v, (value) => self.v = value), src); +} + +/** + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u16(0x0809); + * assert_eq!(buf, b"\x08\x09"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU16$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.u16): void { + rs.byteVecPutWord(self.v, n, 2, false); +} + +/** + * Writes an unsigned 16 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 2. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u16(0x0809); + * assert_eq!(buf, b"\x08\x09"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU16$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u16): void { + rs.bytesMutPutWord(self.v, n, 2, false); +} + +/** + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32(0x0809A0A1); + * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.u32): void { + rs.byteVecPutWord(self.v, n, 4, false); +} + +/** + * Writes an unsigned 32 bit integer to `self` in big-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32(0x0809A0A1); + * assert_eq!(buf, b"\x08\x09\xA0\xA1"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u32): void { + rs.bytesMutPutWord(self.v, n, 4, false); +} + +/** + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32Le$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.Place, n: rs.u32): void { + putU32Le$bytes_BufMut_mut_bytes_BytesMut(rs.place(() => self.v, (value) => self.v = value), n); +} + +/** + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32Le$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place>, n: rs.u32): void { + putU32Le$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(rs.place(() => self.v, (value) => self.v = value), n); +} + +/** + * Writes an unsigned 32 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 4. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u32_le(0x0809A0A1); + * assert_eq!(buf, b"\xA1\xA0\x09\x08"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU32Le$bytes_BufMut_boxed_Box_mut_mut_slice_u8(self: rs.Place>, n: rs.u32): void { + putU32Le$bytes_BufMut_mut_mut_slice_u8(rs.place(() => self.v, (value) => self.v = value), n); +} + +/** + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64_le(0x0102030405060708); + * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64Le$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.u64): void { + rs.byteVecPutBytes(self.v, rs.u64ToBeBytes(n), true); +} + +/** + * Writes an unsigned 64 bit integer to `self` in little-endian byte order. + * + * The current position is advanced by 8. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u64_le(0x0102030405060708); + * assert_eq!(buf, b"\x08\x07\x06\x05\x04\x03\x02\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU64Le$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u64): void { + rs.bytesMutPutBytes(self.v, rs.u64ToBeBytes(n), true); +} + +/** + * Writes an unsigned 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU8$bytes_BufMut_boxed_Box_Vec_u8(self: rs.Place, n: rs.u8): void { + rs.byteVecPutWord(self.v, n, 1, false); +} + +/** + * Writes an unsigned 8 bit integer to `self`. + * + * The current position is advanced by 1. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = vec![]; + * buf.put_u8(0x01); + * assert_eq!(buf, b"\x01"); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putU8$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.Place, n: rs.u8): void { + rs.bytesMutPutWord(self.v, n, 1, false); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_boxed_Box_Vec_u8(self: rs.ByteVec): rs.usize { + return 0x7fffffff - self.length as rs.usize; +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_boxed_Box_bytes_BytesMut(self: rs.BytesMut): rs.usize { + return 0x7fffffff - self.length as rs.usize; +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.BytesMut): rs.usize { + return remainingMut$bytes_BufMut_mut_bytes_BytesMut(self); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_boxed_Box_mut_mut_slice_mem_MaybeUninit_u8(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_mut_mut_slice_mem_MaybeUninit_u8(self); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_boxed_Box_mut_mut_slice_u8(self: rs.Place): rs.usize { + return remainingMut$bytes_BufMut_mut_mut_slice_u8(self); +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_slice_u8(self: rs.ByteSlice): rs.usize { + return self.length; +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_mut_slice_u8(self: rs.Place): rs.ByteSlice { + return UninitSlice.new(self.v); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. */ -export function remainingMut$bytes_BufMut_boxed_Box_mut_bytes_BytesMut(self: rs.BytesMut): rs.usize { - return remainingMut$bytes_BufMut_mut_bytes_BytesMut(self); +export function advanceMut$bytes_BufMut_mut_slice_u8(self: rs.Place, cnt: rs.usize): void { + if (!(self.v.length < cnt)) { + const taken = self.v; + self.v = rs.byteSliceFrom(new Uint8Array(0)); + self.v = rs.byteSliceSplitAt(taken, cnt)[1]; + } else { + panicAdvance({ requested: cnt, available: self.v.length }); + } +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_mut_slice_u8(self: rs.Place, src: rs.ByteSlice): void { + if (!(self.v.length < src.length)) { + rs.byteSliceCopyFromSlice(rs.byteSliceRange(self.v, 0, src.length), src); + advanceMut$bytes_BufMut_mut_slice_u8(self, src.length); + } else { + panicAdvance({ requested: src.length, available: self.v.length }); + } +} + +/** + * Put `cnt` bytes `val` into `self`. + * + * Logically equivalent to calling `self.put_u8(val)` `cnt` times, but may work faster. + * + * `self` must have at least `cnt` remaining capacity. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_bytes(b'a', 4); + * + * assert_eq!(2, buf.remaining_mut()); + * } + * + * assert_eq!(b"aaaa\0\0", &dst); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putBytes$bytes_BufMut_mut_slice_u8(self: rs.Place, val: rs.u8, cnt: rs.usize): void { + if (!(self.v.length < cnt)) { + rs.ptrWriteBytes(rs.byteSliceAsPtr(self.v), val, cnt); + advanceMut$bytes_BufMut_mut_slice_u8(self, cnt); + } else { + panicAdvance({ requested: cnt, available: self.v.length }); + } +} + +/** + * Returns the number of bytes that can be written from the current + * position until the end of the buffer is reached. + * + * This value is greater than or equal to the length of the slice returned + * by `chunk_mut()`. + * + * Writing to a `BufMut` may involve allocating more memory on the fly. + * Implementations may fail before reaching the number of bytes indicated + * by this method if they encounter an allocation failure. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 10]; + * let mut buf = &mut dst[..]; + * + * let original_remaining = buf.remaining_mut(); + * buf.put(&b"hello"[..]); + * + * assert_eq!(original_remaining - 5, buf.remaining_mut()); + * ``` + * + * # Implementer notes + * + * Implementations of `remaining_mut` should ensure that the return value + * does not change unless a call is made to `advance_mut` or any other + * function that is documented to change the `BufMut`'s current position. + * + * # Note + * + * `remaining_mut` may return value smaller than actual available space. + */ +export function remainingMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.ByteSlice): rs.usize { + return self.length; +} + +/** + * Returns a mutable slice starting at the current BufMut position and of + * length between 0 and `BufMut::remaining_mut()`. Note that this *can* be shorter than the + * whole remainder of the buffer (this allows non-continuous implementation). + * + * This is a lower level function. Most operations are done with other + * functions. + * + * The returned byte slice may represent uninitialized memory. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * unsafe { + * // MaybeUninit::as_mut_ptr + * buf.chunk_mut()[0..].as_mut_ptr().write(b'h'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'e'); + * + * buf.advance_mut(2); + * + * buf.chunk_mut()[0..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[1..].as_mut_ptr().write(b'l'); + * buf.chunk_mut()[2..].as_mut_ptr().write(b'o'); + * + * buf.advance_mut(3); + * } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Implementer notes + * + * This function should never panic. `chunk_mut()` should return an empty + * slice **if and only if** `remaining_mut()` returns 0. In other words, + * `chunk_mut()` returning an empty slice implies that `remaining_mut()` will + * return 0 and `remaining_mut()` returning 0 implies that `chunk_mut()` will + * return an empty slice. + * + * This function may trigger an out-of-memory abort if it tries to allocate + * memory and fails to do so. + */ +export function chunkMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place): rs.ByteSlice { + return UninitSlice.uninit(self.v); +} + +/** + * Advance the internal cursor of the BufMut + * + * The next call to `chunk_mut` will return a slice starting `cnt` bytes + * further into the underlying buffer. + * + * # Safety + * + * The caller must ensure that the next `cnt` bytes of `chunk` are + * initialized. + * + * # Examples + * + * ``` + * use bytes::BufMut; + * + * let mut buf = Vec::with_capacity(16); + * + * // Write some data + * buf.chunk_mut()[0..2].copy_from_slice(b"he"); + * unsafe { buf.advance_mut(2) }; + * + * // write more bytes + * buf.chunk_mut()[0..3].copy_from_slice(b"llo"); + * + * unsafe { buf.advance_mut(3); } + * + * assert_eq!(5, buf.len()); + * assert_eq!(buf, b"hello"); + * ``` + * + * # Panics + * + * This function **may** panic if `cnt > self.remaining_mut()`. + * + * # Implementer notes + * + * It is recommended for implementations of `advance_mut` to panic if + * `cnt > self.remaining_mut()`. If the implementation does not panic, + * the call must behave as if `cnt == self.remaining_mut()`. + * + * A call with `cnt == 0` should never panic and be a no-op. + */ +export function advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, cnt: rs.usize): void { + if (!(self.v.length < cnt)) { + const taken = self.v; + self.v = rs.byteSliceFrom(new Uint8Array(0)); + self.v = rs.byteSliceSplitAt(taken, cnt)[1]; + } else { + panicAdvance({ requested: cnt, available: self.v.length }); + } +} + +/** + * Transfer bytes into `self` from `src` and advance the cursor by the + * number of bytes written. + * + * `self` must have enough remaining capacity to contain all of `src`. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_slice(b"hello"); + * + * assert_eq!(1, buf.remaining_mut()); + * } + * + * assert_eq!(b"hello\0", &dst); + * ``` + */ +export function putSlice$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, src: rs.ByteSlice): void { + if (!(self.v.length < src.length)) { + rs.ptrCopy(rs.byteSliceAsPtr(src), rs.byteSliceAsPtr(self.v), src.length); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, src.length); + } else { + panicAdvance({ requested: src.length, available: self.v.length }); + } +} + +/** + * Put `cnt` bytes `val` into `self`. + * + * Logically equivalent to calling `self.put_u8(val)` `cnt` times, but may work faster. + * + * `self` must have at least `cnt` remaining capacity. + * + * ``` + * use bytes::BufMut; + * + * let mut dst = [0; 6]; + * + * { + * let mut buf = &mut dst[..]; + * buf.put_bytes(b'a', 4); + * + * assert_eq!(2, buf.remaining_mut()); + * } + * + * assert_eq!(b"aaaa\0\0", &dst); + * ``` + * + * # Panics + * + * This function panics if there is not enough remaining capacity in + * `self`. + */ +export function putBytes$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self: rs.Place, val: rs.u8, cnt: rs.usize): void { + if (!(self.v.length < cnt)) { + rs.ptrWriteBytes(rs.byteSliceAsPtr(self.v), val, cnt); + advanceMut$bytes_BufMut_mut_slice_mem_MaybeUninit_u8(self, cnt); + } else { + panicAdvance({ requested: cnt, available: self.v.length }); + } } //# sourceMappingURL=buf_mut.ts.map diff --git a/ts/fixtures/stock/expected/harness.ts b/ts/fixtures/stock/expected/harness.ts index 91bd9164d..b04430a49 100644 --- a/ts/fixtures/stock/expected/harness.ts +++ b/ts/fixtures/stock/expected/harness.ts @@ -1,7 +1,7 @@ // Generated by rust2-ts. Do not edit. import * as rs from "./rs.ts"; -import { bytesMut, far, reclaims, reads, deques, dyns, late, vecSpares, chunks, writes, edits, owners, chains, vectored, strings } from "./buf.ts"; +import { bytesMut, far, reclaims, reads, deques, dyns, late, vecSpares, chunks, slices as buf_slices, writes, edits, owners, chains, vectored, strings } from "./buf.ts"; import * as Owner from "./harness.Owner.ts"; import { map as maps_map, table, capacity, linked, linkedIters, nested, ownHasher, ownFromIter, equal, defaultHasher } from "./maps.ts"; import { ranges } from "./ranges.ts"; @@ -43,7 +43,9 @@ export function cases(): rs.Vec<[string, (a0: rs.ByteSlice, a1: rs.ByteVec) => u owners(a015.data, a015.start, a015.length, a115); }] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined], ["buf::strings", strings as (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined], ["ranges", ranges as (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined], ["buf::deques", (a016: rs.ByteSlice, a116: rs.ByteVec): undefined => { deques(a016.data, a016.start, a016.length, a116); - }] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined], ["buf::vectored", vectored as (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined]]); + }] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined], ["buf::vectored", vectored as (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined], ["buf::slices", (a017: rs.ByteSlice, a117: rs.ByteVec): undefined => { + buf_slices(a017.data, a017.start, a017.length, a117); + }] as [string, (a0: rs.ByteSlice, a1: rs.ByteVec) => undefined]]); } /** Run one case. */ diff --git a/ts/fixtures/stock/src/buf.rs b/ts/fixtures/stock/src/buf.rs index 5a9ad6d01..c1b165e24 100644 --- a/ts/fixtures/stock/src/buf.rs +++ b/ts/fixtures/stock/src/buf.rs @@ -4,6 +4,7 @@ use std::cell::Cell; use std::collections::VecDeque; use std::io::IoSlice; +use std::mem::MaybeUninit; use std::rc::Rc; use std::sync::{Arc, Mutex}; @@ -601,9 +602,9 @@ pub fn vec_spares(data: &[u8], out: &mut Vec) { vec.set_len(vec.len() + k); }, 3 => { - spare[..k].fill(std::mem::MaybeUninit::new(n)); + spare[..k].fill(MaybeUninit::new(n)); if let Some(slot) = spare[..k].split_at_mut(k / 2).0.last_mut() { - *slot = std::mem::MaybeUninit::new(!n); + *slot = MaybeUninit::new(!n); } unsafe { vec.set_len(vec.len() + k) }; } @@ -784,6 +785,65 @@ unsafe impl BufMut for Spare { } } +/// Writes into an array through a `&mut [u8]` and a `&mut [MaybeUninit]` of the room +/// its input picks, which write at the front and advance past what they wrote, or panic +/// past the room, directly, through a `&mut`, and through a `Box`: the room left, then +/// each array whole, so a write that missed it or landed off the front would show. +pub fn slices(data: &[u8], out: &mut Vec) { + let [kind, room, data @ ..] = data else { + return; + }; + let room = usize::from(*room); + let mut bytes = [0xa5; 255]; + let mut uninit = [MaybeUninit::new(0x5a); 255]; + let left = match kind % 8 { + 0 => { + let mut s = &mut bytes[..room]; + write_all(&mut s, data); + s.len() + } + 1 => { + let mut s = &mut bytes[..room]; + chunk_all(&mut s, data, out); + s.len() + } + 2 => { + let mut s = &mut uninit[..room]; + write_all(&mut s, data); + s.len() + } + 3 => { + let mut s = &mut uninit[..room]; + chunk_all(&mut s, data, out); + s.len() + } + 4 => { + let mut s = &mut bytes[..room]; + write_all(&mut &mut s, data); + s.len() + } + 5 => { + let mut s = &mut uninit[..room]; + chunk_all(&mut Box::new(&mut s), data, out); + s.len() + } + 6 => { + let mut s = &mut bytes[..room]; + chunk_all(&mut Box::new(&mut s), data, out); + s.len() + } + _ => { + let mut s = &mut uninit[..room]; + write_all(&mut &mut s, data); + s.len() + } + }; + out.push(left as u8); + out.extend_from_slice(&bytes); + // SAFETY: every slot starts initialized, and a write leaves it so. + out.extend(uninit.iter().map(|b| unsafe { b.assume_init() })); +} + /// The same writes into a `Vec` and a `BytesMut`, which must match, and through the /// impls forwarding through a `&mut` and a `Box`, whose provided `put` and `put_bytes` /// grow by `chunk_mut` instead: the bytes, and each vector's capacity. diff --git a/ts/fixtures/stock/src/harness.rs b/ts/fixtures/stock/src/harness.rs index 8bf100e8f..0a8b4723b 100644 --- a/ts/fixtures/stock/src/harness.rs +++ b/ts/fixtures/stock/src/harness.rs @@ -41,6 +41,7 @@ fn cases() -> Vec<(&'static str, Case)> { ("ranges", crate::ranges::ranges), ("buf::deques", crate::buf::deques), ("buf::vectored", crate::buf::vectored), + ("buf::slices", crate::buf::slices), ] } diff --git a/ts/runtime/rs.ts b/ts/runtime/rs.ts index e1f77d1f2..4ea39fca9 100644 --- a/ts/runtime/rs.ts +++ b/ts/runtime/rs.ts @@ -450,6 +450,14 @@ export function ptrCopy(src: Place, dst: Place, n: number, copy?: (valu for (let i = 0; i < n; i++) elemSet(to.array, to.index + i, copy && values[i] !== undefined ? copy(values[i]) : values[i]); } +/** `ptr::write_bytes` of a pointer to bytes: `n` of them from `dst` set to `val`. */ +export function ptrWriteBytes(dst: Place, val: number, n: number): void { + if (n === 0) return; + const to = elemOf(dst); + to.reach(n); + for (let i = 0; i < n; i++) elemSet(to.array, to.index + i, val); +} + /** Element `i` of `array`, or of the room past it, which `AtIndex.reach` found. */ function elemGet(array: { [i: number]: T }, i: number): T { return i < (array as ArrayLike).length ? array[i] : (roomPast(array, i + 1) as Room).get(i); diff --git a/ts/src/lower/mir/origin.rs b/ts/src/lower/mir/origin.rs index e15fe3455..4bd3cf011 100644 --- a/ts/src/lower/mir/origin.rs +++ b/ts/src/lower/mir/origin.rs @@ -152,6 +152,7 @@ impl<'tcx> Fx<'_, '_, '_, 'tcx> { .into_iter() .find_map(|p| out(self.origin(p)?, n, "a copy")) } + ("ptr" | "NonNull", "write_bytes") => out(self.origin(arg(0)?)?, self.const_int(arg(2)?), "a write"), _ => None, } } diff --git a/ts/src/lower/pointer.rs b/ts/src/lower/pointer.rs index dc6ef7636..08bbf092a 100644 --- a/ts/src/lower/pointer.rs +++ b/ts/src/lower/pointer.rs @@ -916,6 +916,24 @@ pub fn call<'tcx>( Expr::rs("ptrCopy", args) } } + ("ptr" | "NonNull", "write_bytes") => { + let (p, val, n) = (arg(), arg(), arg()); + if b.t.zero_sized(pointee()) { + out.push(StmtKind::Expr(n).at(None)); + Expr::undefined() + } else if super::byte(pointee()) { + Expr::rs("ptrWriteBytes", vec![p, val, n]) + } else { + // Only a byte is the byte it is set to: JS keeps any other element as a value. + b.err( + span, + format!( + "`write_bytes` of a pointer to `{}`, whose bytes JS keeps as a value", + pointee() + ), + ) + } + } ("raw", "from_raw_parts" | "from_raw_parts_mut") | ("ptr", "slice_from_raw_parts" | "slice_from_raw_parts_mut") | ("NonNull", "slice_from_raw_parts") => { diff --git a/ts/src/lower/stock.rs b/ts/src/lower/stock.rs index eaf3e1a78..90567f253 100644 --- a/ts/src/lower/stock.rs +++ b/ts/src/lower/stock.rs @@ -88,10 +88,10 @@ pub fn is_opaque_crate(tcx: TyCtxt<'_>, krate: CrateNum) -> bool { } /// Whether `did`, an item of `bytes`, has a mapping in place of its MIR: `Bytes`, -/// `BytesMut`, and their functions and impls, and the crate's impls of std's byte slices +/// `BytesMut`, and their functions and impls, and the crate's impls of std's shared byte slices /// and vectors. The mapping of a function stands in for it or refuses it. The impls that /// forward through a reference or a `Box`, and the crate's other types and functions, -/// translate, as does its impl for a `VecDeque`. +/// translate, as do its impls for a `VecDeque` and a `&mut [u8]`. pub fn mapped(tcx: TyCtxt<'_>, did: DefId) -> bool { if tcx.crate_name(did.krate).as_str() != "bytes" { return false; @@ -267,11 +267,12 @@ impl Buffer { /// Whether `ty`, the `Self` of a function of `bytes`, has a representation of its own or /// is std's, so a mapping stands in for its impls: not a type parameter, through which an /// impl forwards, nor the crate's own buffer or another crate's, nor a `VecDeque`, -/// whose impl reads the slices the runtime's deque has, which translate. +/// whose impl reads the slices the runtime's deque has, nor a `&mut [u8]`, whose impl +/// writes its front and moves past it, which translate. fn mapped_self<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { match ty.kind() { ty::Adt(adt, _) => library::Std::of(tcx, adt.did()).is_some_and(|std| std != Std::VecDeque) && !ty.has_param(), - ty::Ref(_, inner, _) => matches!(inner.kind(), ty::Slice(e) if is_u8(*e)), + ty::Ref(_, inner, ty::Mutability::Not) => matches!(inner.kind(), ty::Slice(e) if is_u8(*e)), _ => false, } } From 0de9208600994217a125a9ca574882d7624a8b49 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Sat, 7 Nov 2026 00:54:21 -0800 Subject: [PATCH 3/3] fix(ts): name write_bytes verbatim in the census Co-Authored-By: Claude Opus 5.5 --- ts/src/census.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ts/src/census.rs b/ts/src/census.rs index 55d1c8516..d71ef11e3 100644 --- a/ts/src/census.rs +++ b/ts/src/census.rs @@ -204,6 +204,7 @@ const VERBATIM: &[&str] = &[ "self", "skip", "undefined", + "write_bytes", "write_str", "zip", "{:.2}",