|
|
@ -299,7 +299,7 @@ impl_raw_vtable_mutator_get_set!(bool, f32, f64, i32, i64, u32, u64); |
|
|
|
#[doc(hidden)] |
|
|
|
#[doc(hidden)] |
|
|
|
#[derive(Debug)] |
|
|
|
#[derive(Debug)] |
|
|
|
pub struct BytesMutVTable { |
|
|
|
pub struct BytesMutVTable { |
|
|
|
pub(crate) setter: unsafe extern "C" fn(msg: RawMessage, val: *const u8, len: usize), |
|
|
|
pub(crate) setter: unsafe extern "C" fn(msg: RawMessage, val: PtrAndLen), |
|
|
|
pub(crate) getter: unsafe extern "C" fn(msg: RawMessage) -> PtrAndLen, |
|
|
|
pub(crate) getter: unsafe extern "C" fn(msg: RawMessage) -> PtrAndLen, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -316,7 +316,7 @@ impl BytesMutVTable { |
|
|
|
pub const fn new( |
|
|
|
pub const fn new( |
|
|
|
_private: Private, |
|
|
|
_private: Private, |
|
|
|
getter: unsafe extern "C" fn(msg: RawMessage) -> PtrAndLen, |
|
|
|
getter: unsafe extern "C" fn(msg: RawMessage) -> PtrAndLen, |
|
|
|
setter: unsafe extern "C" fn(msg: RawMessage, val: *const u8, len: usize), |
|
|
|
setter: unsafe extern "C" fn(msg: RawMessage, val: PtrAndLen), |
|
|
|
) -> Self { |
|
|
|
) -> Self { |
|
|
|
Self { getter, setter } |
|
|
|
Self { getter, setter } |
|
|
|
} |
|
|
|
} |
|
|
@ -330,7 +330,7 @@ impl BytesOptionalMutVTable { |
|
|
|
pub const unsafe fn new( |
|
|
|
pub const unsafe fn new( |
|
|
|
_private: Private, |
|
|
|
_private: Private, |
|
|
|
getter: unsafe extern "C" fn(msg: RawMessage) -> PtrAndLen, |
|
|
|
getter: unsafe extern "C" fn(msg: RawMessage) -> PtrAndLen, |
|
|
|
setter: unsafe extern "C" fn(msg: RawMessage, val: *const u8, len: usize), |
|
|
|
setter: unsafe extern "C" fn(msg: RawMessage, val: PtrAndLen), |
|
|
|
clearer: unsafe extern "C" fn(msg: RawMessage), |
|
|
|
clearer: unsafe extern "C" fn(msg: RawMessage), |
|
|
|
default: &'static [u8], |
|
|
|
default: &'static [u8], |
|
|
|
) -> Self { |
|
|
|
) -> Self { |
|
|
@ -355,7 +355,7 @@ impl<'msg> RawVTableMutator<'msg, [u8]> { |
|
|
|
let val = copy_bytes_in_arena_if_needed_by_runtime(self.msg_ref, val); |
|
|
|
let val = copy_bytes_in_arena_if_needed_by_runtime(self.msg_ref, val); |
|
|
|
// SAFETY:
|
|
|
|
// SAFETY:
|
|
|
|
// - `msg_ref` is valid for `'msg` as promised by the caller of `new`.
|
|
|
|
// - `msg_ref` is valid for `'msg` as promised by the caller of `new`.
|
|
|
|
unsafe { (self.vtable.setter)(self.msg_ref.msg(), val.as_ptr(), val.len()) } |
|
|
|
unsafe { (self.vtable.setter)(self.msg_ref.msg(), val.into()) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub(crate) fn truncate(&self, len: usize) { |
|
|
|
pub(crate) fn truncate(&self, len: usize) { |
|
|
@ -385,7 +385,7 @@ impl<'msg> RawVTableOptionalMutatorData<'msg, [u8]> { |
|
|
|
let val = copy_bytes_in_arena_if_needed_by_runtime(self.msg_ref, val); |
|
|
|
let val = copy_bytes_in_arena_if_needed_by_runtime(self.msg_ref, val); |
|
|
|
// SAFETY:
|
|
|
|
// SAFETY:
|
|
|
|
// - `msg_ref` is valid for `'msg` as promised by the caller.
|
|
|
|
// - `msg_ref` is valid for `'msg` as promised by the caller.
|
|
|
|
unsafe { (self.vtable.base.setter)(self.msg_ref.msg(), val.as_ptr(), val.len()) } |
|
|
|
unsafe { (self.vtable.base.setter)(self.msg_ref.msg(), val.into()) } |
|
|
|
self |
|
|
|
self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|