mozilla / uniffi-rs

a multi-language bindings generator for rust
https://mozilla.github.io/uniffi-rs/
Mozilla Public License 2.0
2.48k stars 211 forks source link

Make `RustBuffer::from_raw_parts` comment more precise #2166

Closed mgeisler closed 1 hour ago

mgeisler commented 1 week ago

The method is used from outside of this module, so the comment seems unnecessary: the method should either be private or it should be public.

mhammond commented 1 week ago

I wonder if we can make it private? I'm on a bit of a mission to reduce the api surface as much as possible before we move towards a 1.0, just so we don't accidentally force ourselves to have a change be "breaking" when it isn't in practice (which IIUC, mislabeling a private method as public risks)

mgeisler commented 1 week ago

Yes, making it private would be great! :smile:

Cc @badboy, a small note from my import review.

badboy commented 1 week ago

I wonder if we can make it private? I'm on a bit of a mission to reduce the api surface as much as possible before we move towards a 1.0, just so we don't accidentally force ourselves to have a change be "breaking" when it isn't in practice (which IIUC, mislabeling a private method as public risks)

error[E0624]: associated function `from_raw_parts` is private
  --> uniffi_core/src/ffi/ffidefault.rs:56:24
   |
56 |         unsafe { Self::from_raw_parts(std::ptr::null_mut(), 0, 0) }
   |                        ^^^^^^^^^^^^^^ private associated function
   |
  ::: uniffi_core/src/ffi/rustbuffer.rs:87:5
   |
87 |     unsafe fn from_raw_parts(data: *mut u8, len: u64, capacity: u64) -> Self {
   |     ------------------------------------------------------------------------ private associated function defined here

error[E0624]: associated function `from_raw_parts` is private
   --> uniffi_core/src/ffi/ffiserialize.rs:213:37
    |
213 |         unsafe { crate::RustBuffer::from_raw_parts(data, len, capacity) }
    |                                     ^^^^^^^^^^^^^^ private associated function
    |
   ::: uniffi_core/src/ffi/rustbuffer.rs:87:5
    |
87  |     unsafe fn from_raw_parts(data: *mut u8, len: u64, capacity: u64) -> Self {
    |     ------------------------------------------------------------------------ private associated function defined here

well, I guess we didn't follow our own advice :D

badboy commented 1 week ago

It can at the very leat be pub(crate)

mgeisler commented 1 week ago

It can at the very leat be pub(crate)

Done!