Turn on 'CheckRequired' option on upb decode

PiperOrigin-RevId: 643028693
pull/17138/head
Protobuf Team Bot 9 months ago committed by Copybara-Service
parent 2eb4d69ed5
commit d471c874e3
  1. 12
      rust/upb/wire.rs

@ -26,6 +26,14 @@ pub enum DecodeStatus {
} }
// LINT.ThenChange() // LINT.ThenChange()
#[repr(i32)]
enum DecodeOption {
AliasString = 1,
CheckRequired = 2,
ExperimentalAllowUnlinked = 4,
AlwaysValidateUtf8 = 8,
}
/// If Err, then EncodeStatus != Ok. /// If Err, then EncodeStatus != Ok.
/// ///
/// SAFETY: /// SAFETY:
@ -67,11 +75,13 @@ pub unsafe fn decode(
) -> Result<(), DecodeStatus> { ) -> Result<(), DecodeStatus> {
let len = buf.len(); let len = buf.len();
let buf = buf.as_ptr(); let buf = buf.as_ptr();
let options = DecodeOption::CheckRequired as i32;
// SAFETY: // SAFETY:
// - `mini_table` is the one associated with `msg` // - `mini_table` is the one associated with `msg`
// - `buf` is legally readable for at least `buf_size` bytes. // - `buf` is legally readable for at least `buf_size` bytes.
// - `extreg` is null. // - `extreg` is null.
let status = upb_Decode(buf, len, msg, mini_table, std::ptr::null(), 0, arena.raw()); let status = upb_Decode(buf, len, msg, mini_table, std::ptr::null(), options, arena.raw());
match status { match status {
DecodeStatus::Ok => Ok(()), DecodeStatus::Ok => Ok(()),
_ => Err(status), _ => Err(status),

Loading…
Cancel
Save