1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2024 Google LLC. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 use super::{RawArray, RawMap, RawMessage, StringView}; 9 10 // Transcribed from google3/third_party/upb/upb/message/value.h 11 #[repr(C)] 12 #[derive(Clone, Copy)] 13 pub union upb_MessageValue { 14 pub bool_val: bool, 15 pub float_val: core::ffi::c_float, 16 pub double_val: core::ffi::c_double, 17 pub uint32_val: u32, 18 pub int32_val: i32, 19 pub uint64_val: u64, 20 pub int64_val: i64, 21 // TODO: Replace this `RawMessage` with the const type. 22 pub array_val: Option<RawArray>, 23 pub map_val: Option<RawMap>, 24 pub msg_val: Option<RawMessage>, 25 pub str_val: StringView, 26 27 tagged_msg_val: *const core::ffi::c_void, 28 } 29 30 impl upb_MessageValue { zeroed() -> Self31 pub fn zeroed() -> Self { 32 // SAFETY: zero bytes is a valid representation for at least one value in the 33 // union (actually valid for all of them). 34 unsafe { core::mem::zeroed() } 35 } 36 } 37 38 #[repr(C)] 39 #[derive(Clone, Copy)] 40 pub union upb_MutableMessageValue { 41 pub array: Option<RawArray>, 42 pub map: Option<RawMap>, 43 pub msg: Option<RawMessage>, 44 } 45