Skip to content

Commit 65667cb

Browse files
committed
Rename ProtobufValueRef to ReflectValueRef
Old name is kept for compatibility
1 parent 60cba9e commit 65667cb

File tree

5 files changed

+101
-99
lines changed

5 files changed

+101
-99
lines changed

protobuf/src/reflect/accessor.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::repeated::ReflectRepeated;
2020
use super::repeated::ReflectRepeatedEnum;
2121
use super::repeated::ReflectRepeatedMessage;
2222
use super::value::ProtobufValue;
23-
use super::value::ProtobufValueRef;
23+
use super::value::ReflectValueRef;
2424
use super::ReflectFieldRef;
2525

2626
/// this trait should not be used directly, use `FieldDescriptor` instead
@@ -85,7 +85,7 @@ trait GetRepeatedEnum<M: Message + 'static> {
8585
}
8686

8787
trait GetSetCopyFns<M> {
88-
fn get_field<'a>(&self, m: &'a M) -> ProtobufValueRef<'a>;
88+
fn get_field<'a>(&self, m: &'a M) -> ReflectValueRef<'a>;
8989
}
9090

9191
struct GetSetCopyFnsImpl<M, V: ProtobufValue + Copy> {
@@ -94,7 +94,7 @@ struct GetSetCopyFnsImpl<M, V: ProtobufValue + Copy> {
9494
}
9595

9696
impl<M, V: ProtobufValue + Copy> GetSetCopyFns<M> for GetSetCopyFnsImpl<M, V> {
97-
fn get_field<'a>(&self, m: &'a M) -> ProtobufValueRef<'a> {
97+
fn get_field<'a>(&self, m: &'a M) -> ReflectValueRef<'a> {
9898
(&(self.get)(m) as &ProtobufValue).as_ref_copy()
9999
}
100100
}
@@ -108,13 +108,13 @@ enum SingularGetSet<M> {
108108
}
109109

110110
impl<M: Message + 'static> SingularGetSet<M> {
111-
fn get_ref<'a>(&self, m: &'a M) -> ProtobufValueRef<'a> {
111+
fn get_ref<'a>(&self, m: &'a M) -> ReflectValueRef<'a> {
112112
match self {
113113
&SingularGetSet::Copy(ref copy) => copy.get_field(m),
114-
&SingularGetSet::String(get, _) => ProtobufValueRef::String(get(m)),
115-
&SingularGetSet::Bytes(get, _) => ProtobufValueRef::Bytes(get(m)),
116-
&SingularGetSet::Enum(ref get) => ProtobufValueRef::Enum(get.get_enum(m)),
117-
&SingularGetSet::Message(ref get) => ProtobufValueRef::Message(get.get_message(m)),
114+
&SingularGetSet::String(get, _) => ReflectValueRef::String(get(m)),
115+
&SingularGetSet::Bytes(get, _) => ReflectValueRef::Bytes(get(m)),
116+
&SingularGetSet::Enum(ref get) => ReflectValueRef::Enum(get.get_enum(m)),
117+
&SingularGetSet::Message(ref get) => ReflectValueRef::Message(get.get_message(m)),
118118
}
119119
}
120120
}
@@ -171,7 +171,7 @@ struct FieldAccessorImpl<M> {
171171
}
172172

173173
impl<M: Message> FieldAccessorImpl<M> {
174-
fn get_value_option<'a>(&self, m: &'a M) -> Option<ProtobufValueRef<'a>> {
174+
fn get_value_option<'a>(&self, m: &'a M) -> Option<ReflectValueRef<'a>> {
175175
match self.fns {
176176
FieldAccessorFunctions::Repeated(..) | FieldAccessorFunctions::Map(..) => {
177177
panic!("repeated")
@@ -239,7 +239,7 @@ impl<M: Message + 'static> FieldAccessor for FieldAccessorImpl<M> {
239239
.expect("field unset")
240240
.as_ref()
241241
{
242-
ProtobufValueRef::Message(m) => m,
242+
ReflectValueRef::Message(m) => m,
243243
_ => panic!("not a message"),
244244
}
245245
}
@@ -259,71 +259,71 @@ impl<M: Message + 'static> FieldAccessor for FieldAccessorImpl<M> {
259259

260260
fn get_str_generic<'a>(&self, m: &'a Message) -> &'a str {
261261
match self.get_value_option(message_down_cast(m)) {
262-
Some(ProtobufValueRef::String(v)) => v,
262+
Some(ReflectValueRef::String(v)) => v,
263263
Some(_) => panic!("wrong type"),
264264
None => "", // TODO: check type
265265
}
266266
}
267267

268268
fn get_bytes_generic<'a>(&self, m: &'a Message) -> &'a [u8] {
269269
match self.get_value_option(message_down_cast(m)) {
270-
Some(ProtobufValueRef::Bytes(v)) => v,
270+
Some(ReflectValueRef::Bytes(v)) => v,
271271
Some(_) => panic!("wrong type"),
272272
None => b"", // TODO: check type
273273
}
274274
}
275275

276276
fn get_u32_generic(&self, m: &Message) -> u32 {
277277
match self.get_value_option(message_down_cast(m)) {
278-
Some(ProtobufValueRef::U32(v)) => v,
278+
Some(ReflectValueRef::U32(v)) => v,
279279
Some(_) => panic!("wrong type"),
280280
None => 0, // TODO: check type
281281
}
282282
}
283283

284284
fn get_u64_generic(&self, m: &Message) -> u64 {
285285
match self.get_value_option(message_down_cast(m)) {
286-
Some(ProtobufValueRef::U64(v)) => v,
286+
Some(ReflectValueRef::U64(v)) => v,
287287
Some(_) => panic!("wrong type"),
288288
None => 0, // TODO: check type
289289
}
290290
}
291291

292292
fn get_i32_generic(&self, m: &Message) -> i32 {
293293
match self.get_value_option(message_down_cast(m)) {
294-
Some(ProtobufValueRef::I32(v)) => v,
294+
Some(ReflectValueRef::I32(v)) => v,
295295
Some(_) => panic!("wrong type"),
296296
None => 0, // TODO: check type
297297
}
298298
}
299299

300300
fn get_i64_generic(&self, m: &Message) -> i64 {
301301
match self.get_value_option(message_down_cast(m)) {
302-
Some(ProtobufValueRef::I64(v)) => v,
302+
Some(ReflectValueRef::I64(v)) => v,
303303
Some(_) => panic!("wrong type"),
304304
None => 0, // TODO: check type
305305
}
306306
}
307307

308308
fn get_f32_generic(&self, m: &Message) -> f32 {
309309
match self.get_value_option(message_down_cast(m)) {
310-
Some(ProtobufValueRef::F32(v)) => v,
310+
Some(ReflectValueRef::F32(v)) => v,
311311
Some(_) => panic!("wrong type"),
312312
None => 0.0, // TODO: check type
313313
}
314314
}
315315

316316
fn get_f64_generic(&self, m: &Message) -> f64 {
317317
match self.get_value_option(message_down_cast(m)) {
318-
Some(ProtobufValueRef::F64(v)) => v,
318+
Some(ReflectValueRef::F64(v)) => v,
319319
Some(_) => panic!("wrong type"),
320320
None => 0.0, // TODO: check type
321321
}
322322
}
323323

324324
fn get_bool_generic(&self, m: &Message) -> bool {
325325
match self.get_value_option(message_down_cast(m)) {
326-
Some(ProtobufValueRef::Bool(v)) => v,
326+
Some(ReflectValueRef::Bool(v)) => v,
327327
Some(_) => panic!("wrong type"),
328328
None => false, // TODO: check type
329329
}

protobuf/src/reflect/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ use self::map::ReflectMap;
2727
use self::repeated::ReflectRepeated;
2828

2929
pub use self::value::ProtobufValue;
30-
pub use self::value::ProtobufValueRef;
30+
pub use self::value::ReflectValueRef;
31+
#[doc(hidden)]
32+
pub use self::value::ReflectValueRef as ProtobufValueRef;
3133

3234
pub use self::field::FieldDescriptor;
3335

@@ -241,5 +243,5 @@ pub enum ReflectFieldRef<'a> {
241243
/// Map field
242244
Map(&'a ReflectMap),
243245
/// Optional field
244-
Optional(Option<ProtobufValueRef<'a>>),
246+
Optional(Option<ReflectValueRef<'a>>),
245247
}

protobuf/src/reflect/repeated.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::slice;
22

33
use super::value::ProtobufValue;
4-
use super::value::ProtobufValueRef;
4+
use super::value::ReflectValueRef;
55

66
use repeated::RepeatedField;
77

@@ -100,13 +100,13 @@ impl<'a> IntoIterator for &'a ReflectRepeated {
100100
pub trait ReflectRepeatedEnum<'a> {
101101
fn len(&self) -> usize;
102102

103-
fn get(&self, index: usize) -> ProtobufValueRef<'a>;
103+
fn get(&self, index: usize) -> ReflectValueRef<'a>;
104104
}
105105

106106
pub trait ReflectRepeatedMessage<'a> {
107107
fn len(&self) -> usize;
108108

109-
fn get(&self, index: usize) -> ProtobufValueRef<'a>;
109+
fn get(&self, index: usize) -> ReflectValueRef<'a>;
110110
}
111111

112112
pub enum ReflectRepeatedRef<'a> {
@@ -142,18 +142,18 @@ impl<'a> ReflectRepeatedRef<'a> {
142142
}
143143
}
144144

145-
fn get(&self, index: usize) -> ProtobufValueRef<'a> {
145+
fn get(&self, index: usize) -> ReflectValueRef<'a> {
146146
match *self {
147147
ReflectRepeatedRef::Generic(ref r) => r.get(index).as_ref(),
148-
ReflectRepeatedRef::U32(ref r) => ProtobufValueRef::U32(r[index]),
149-
ReflectRepeatedRef::U64(ref r) => ProtobufValueRef::U64(r[index]),
150-
ReflectRepeatedRef::I32(ref r) => ProtobufValueRef::I32(r[index]),
151-
ReflectRepeatedRef::I64(ref r) => ProtobufValueRef::I64(r[index]),
152-
ReflectRepeatedRef::F32(ref r) => ProtobufValueRef::F32(r[index]),
153-
ReflectRepeatedRef::F64(ref r) => ProtobufValueRef::F64(r[index]),
154-
ReflectRepeatedRef::Bool(ref r) => ProtobufValueRef::Bool(r[index]),
155-
ReflectRepeatedRef::String(ref r) => ProtobufValueRef::String(&r[index]),
156-
ReflectRepeatedRef::Bytes(ref r) => ProtobufValueRef::Bytes(&r[index]),
148+
ReflectRepeatedRef::U32(ref r) => ReflectValueRef::U32(r[index]),
149+
ReflectRepeatedRef::U64(ref r) => ReflectValueRef::U64(r[index]),
150+
ReflectRepeatedRef::I32(ref r) => ReflectValueRef::I32(r[index]),
151+
ReflectRepeatedRef::I64(ref r) => ReflectValueRef::I64(r[index]),
152+
ReflectRepeatedRef::F32(ref r) => ReflectValueRef::F32(r[index]),
153+
ReflectRepeatedRef::F64(ref r) => ReflectValueRef::F64(r[index]),
154+
ReflectRepeatedRef::Bool(ref r) => ReflectValueRef::Bool(r[index]),
155+
ReflectRepeatedRef::String(ref r) => ReflectValueRef::String(&r[index]),
156+
ReflectRepeatedRef::Bytes(ref r) => ReflectValueRef::Bytes(&r[index]),
157157
ReflectRepeatedRef::Enum(ref r) => r.get(index),
158158
ReflectRepeatedRef::Message(ref r) => r.get(index),
159159
}
@@ -166,7 +166,7 @@ pub struct ReflectRepeatedRefIter<'a> {
166166
}
167167

168168
impl<'a> Iterator for ReflectRepeatedRefIter<'a> {
169-
type Item = ProtobufValueRef<'a>;
169+
type Item = ReflectValueRef<'a>;
170170

171171
fn next(&mut self) -> Option<Self::Item> {
172172
if self.pos < self.repeated.len() {
@@ -181,7 +181,7 @@ impl<'a> Iterator for ReflectRepeatedRefIter<'a> {
181181

182182
impl<'a> IntoIterator for &'a ReflectRepeatedRef<'a> {
183183
type IntoIter = ReflectRepeatedRefIter<'a>;
184-
type Item = ProtobufValueRef<'a>;
184+
type Item = ReflectValueRef<'a>;
185185

186186
fn into_iter(self) -> Self::IntoIter {
187187
ReflectRepeatedRefIter {

0 commit comments

Comments
 (0)