Skip to content

Commit

Permalink
rename ID to Term in the protobuf schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Sep 12, 2021
1 parent 2ae46e5 commit a32425a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
30 changes: 15 additions & 15 deletions src/format/convert.rs
Expand Up @@ -264,7 +264,7 @@ pub mod v2 {
pub fn token_predicate_to_proto_predicate(input: &Predicate) -> schema::PredicateV2 {
schema::PredicateV2 {
name: input.name,
ids: input.terms.iter().map(token_term_to_proto_id).collect(),
terms: input.terms.iter().map(token_term_to_proto_id).collect(),
}
}

Expand All @@ -273,8 +273,8 @@ pub mod v2 {
) -> Result<Predicate, error::Format> {
let mut terms = vec![];

for id in input.ids.iter() {
terms.push(proto_id_to_token_term(id)?);
for term in input.terms.iter() {
terms.push(proto_id_to_token_term(term)?);
}

Ok(Predicate {
Expand All @@ -283,38 +283,38 @@ pub mod v2 {
})
}

pub fn token_term_to_proto_id(input: &Term) -> schema::Idv2 {
use schema::idv2::Content;
pub fn token_term_to_proto_id(input: &Term) -> schema::TermV2 {
use schema::term_v2::Content;

match input {
Term::Variable(v) => schema::Idv2 {
Term::Variable(v) => schema::TermV2 {
content: Some(Content::Variable(*v)),
},
Term::Integer(i) => schema::Idv2 {
Term::Integer(i) => schema::TermV2 {
content: Some(Content::Integer(*i)),
},
Term::Str(s) => schema::Idv2 {
Term::Str(s) => schema::TermV2 {
content: Some(Content::String(*s)),
},
Term::Date(d) => schema::Idv2 {
Term::Date(d) => schema::TermV2 {
content: Some(Content::Date(*d)),
},
Term::Bytes(s) => schema::Idv2 {
Term::Bytes(s) => schema::TermV2 {
content: Some(Content::Bytes(s.clone())),
},
Term::Bool(b) => schema::Idv2 {
Term::Bool(b) => schema::TermV2 {
content: Some(Content::Bool(*b)),
},
Term::Set(s) => schema::Idv2 {
content: Some(Content::Set(schema::IdSet {
Term::Set(s) => schema::TermV2 {
content: Some(Content::Set(schema::TermSet {
set: s.iter().map(token_term_to_proto_id).collect(),
})),
},
}
}

pub fn proto_id_to_token_term(input: &schema::Idv2) -> Result<Term, error::Format> {
use schema::idv2::Content;
pub fn proto_id_to_token_term(input: &schema::TermV2) -> Result<Term, error::Format> {
use schema::term_v2::Content;

match &input.content {
None => Err(error::Format::DeserializationError(
Expand Down
14 changes: 7 additions & 7 deletions src/format/schema.proto
Expand Up @@ -47,27 +47,27 @@ message CheckV2 {

message PredicateV2 {
required uint64 name = 1;
repeated IDV2 ids = 2;
repeated TermV2 terms = 2;
}

message IDV2 {
message TermV2 {
oneof Content {
uint32 variable = 1;
int64 integer = 2;
uint64 string = 3;
uint64 date = 4;
bytes bytes = 5;
bool bool = 6;
IDSet set = 7;
TermSet set = 7;
}
}

message IDSet {
repeated IDV2 set = 1;
message TermSet {
repeated TermV2 set = 1;
}

message ConstraintV2 {
required uint32 id = 1;
required uint32 term = 1;

oneof Constraint {
IntConstraintV2 int = 2;
Expand Down Expand Up @@ -133,7 +133,7 @@ message ExpressionV2 {

message Op {
oneof Content {
IDV2 value = 1;
TermV2 value = 1;
OpUnary unary = 2;
OpBinary Binary = 3;
}
Expand Down
22 changes: 11 additions & 11 deletions src/format/schema.rs
Expand Up @@ -72,15 +72,15 @@ pub struct PredicateV2 {
#[prost(uint64, required, tag="1")]
pub name: u64,
#[prost(message, repeated, tag="2")]
pub ids: ::prost::alloc::vec::Vec<Idv2>,
pub terms: ::prost::alloc::vec::Vec<TermV2>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Idv2 {
#[prost(oneof="idv2::Content", tags="1, 2, 3, 4, 5, 6, 7")]
pub content: ::core::option::Option<idv2::Content>,
pub struct TermV2 {
#[prost(oneof="term_v2::Content", tags="1, 2, 3, 4, 5, 6, 7")]
pub content: ::core::option::Option<term_v2::Content>,
}
/// Nested message and enum types in `IDV2`.
pub mod idv2 {
/// Nested message and enum types in `TermV2`.
pub mod term_v2 {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Content {
#[prost(uint32, tag="1")]
Expand All @@ -96,18 +96,18 @@ pub mod idv2 {
#[prost(bool, tag="6")]
Bool(bool),
#[prost(message, tag="7")]
Set(super::IdSet),
Set(super::TermSet),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IdSet {
pub struct TermSet {
#[prost(message, repeated, tag="1")]
pub set: ::prost::alloc::vec::Vec<Idv2>,
pub set: ::prost::alloc::vec::Vec<TermV2>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConstraintV2 {
#[prost(uint32, required, tag="1")]
pub id: u32,
pub term: u32,
#[prost(oneof="constraint_v2::Constraint", tags="2, 3, 4, 5")]
pub constraint: ::core::option::Option<constraint_v2::Constraint>,
}
Expand Down Expand Up @@ -235,7 +235,7 @@ pub mod op {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Content {
#[prost(message, tag="1")]
Value(super::Idv2),
Value(super::TermV2),
#[prost(message, tag="2")]
Unary(super::OpUnary),
#[prost(message, tag="3")]
Expand Down

0 comments on commit a32425a

Please sign in to comment.