dep-protobuf/rust/cpp_kernel
Protobuf Team Bot 7fbb3d2cc7 Make conversion functions for into c++ string types from PtrAndLen.
The invariant is that PtrAndLen may hold ptr+len values which are legal for _either_ C++ string_view or Rust slices: constructing one from either Rust or C++ permits the laxest constraints, and care must be taken when converting a PtrAndLen into either type.

For "into Rust slice" case to handle is that len=0 ptr must be non-null, so len=0 ptr=null gets turned into an arbitrary non-null pointer as provided by std::ptr::NonNull::dangling() (any preexisting non-null ptr is kept in that direction).

For the "into C++ slice" the risk is more obscure that a Rust non-null pointer could potentially be an illegal pointer (such that ptr+0 is not a legal operation in C++), so when going into C++ we map any len=0 cases into ptr=null to avoid this as a possible risk.

PiperOrigin-RevId: 704776210
2024-12-10 11:15:00 -08:00
..
BUILD Make conversion functions for into c++ string types from PtrAndLen. 2024-12-10 11:15:00 -08:00
compare.cc Set up for Rust-cpp Protobuf implementation message matcher. 2024-08-01 07:52:17 -07:00
compare.h Set up for Rust-cpp Protobuf implementation message matcher. 2024-08-01 07:52:17 -07:00
debug.cc Enable MessageLite::DebugString to use Message::DebugString where possible. 2024-07-03 09:37:37 -07:00
debug.h Enable MessageLite::DebugString to use Message::DebugString where possible. 2024-07-03 09:37:37 -07:00
map.cc Make conversion functions for into c++ string types from PtrAndLen. 2024-12-10 11:15:00 -08:00
message.cc Replace some per-message C++ thunks with a common implementation 2024-08-21 09:34:25 -07:00
repeated.cc Rust C++: remove per-message functions for repeated fields 2024-11-05 10:24:35 -08:00
rust_alloc_for_cpp_api.h Change to proto2_rust C prefix and proto2::rust C++ namespace 2024-07-02 11:44:17 -07:00
rust_alloc_for_cpp_api.rs Change to proto2_rust C prefix and proto2::rust C++ namespace 2024-07-02 11:44:17 -07:00
serialized_data.h Make SerializedData into a POD struct. 2024-09-18 14:17:14 -07:00
strings.cc Make conversion functions for into c++ string types from PtrAndLen. 2024-12-10 11:15:00 -08:00
strings.h Make conversion functions for into c++ string types from PtrAndLen. 2024-12-10 11:15:00 -08:00