Skip to content

Commit

Permalink
fix proto build (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn authored Feb 15, 2025
1 parent 4026c05 commit 1ff7e52
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 55 deletions.
4 changes: 4 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v2
plugins:
- remote: buf.build/community/neoeinstein-prost:v0.4.0
out: src/gen
11 changes: 11 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
version: v2
lint:
use:
- STANDARD
breaking:
use:
- FILE

modules:
- path: pb
11 changes: 0 additions & 11 deletions build.rs

This file was deleted.

41 changes: 30 additions & 11 deletions tzinfo.proto → pb/tzf/v1/tzinfo.proto
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
syntax = "proto3";

package pb;
// # tzf's protobuf define
//
// The published data of [tzf-rel](https://github.com/ringsaturn/tzf-rel) and
// [tzf-rel-lite](https://github.com/ringsaturn/tzf-rel-lite) are defined in this
// directory.
//
// Avaliable docs:
//
// - [`tzf.v1` on buf.build](https://buf.build/ringsaturn/tzf/docs/main:tzf.v1)
// - [Plain HTML](https://ringsaturn.github.io/tzf/pb.html)
//
// Related projects:
//
// - [tzf](https://github.com/ringsaturn/tzf)
// - [tzf-rel](https://github.com/ringsaturn/tzf-rel)
// - [tzf-rel-lite](https://github.com/ringsaturn/tzf-rel-lite)
// - [tzf-rs](https://github.com/ringsaturn/tzf-rs)
// - [tzfpy](https://github.com/ringsaturn/tzfpy)
// - [tzf-wasm](https://github.com/ringsaturn/tzf-wasm)
// - [tzf-web](https://github.com/ringsaturn/tzf-web)
package tzf.v1;

option go_package = "github.com/ringsaturn/tzf/pb;pb";
option go_package = "github.com/ringsaturn/tzf/gen/go/tzf/v1;v1";

// Basic Point data define.
// Basic point data define.
message Point {
float lng = 1;
float lat = 2;
Expand Down Expand Up @@ -41,8 +61,8 @@ message Point {
// [GJ2008]: https://geojson.org/geojson-spec
//
message Polygon {
repeated Point points = 1; // define the "exterior ring"
repeated Polygon holes = 2; // define the "interior rings" as holes
repeated Point points = 1; // define the "exterior ring"
repeated Polygon holes = 2; // define the "interior rings" as holes
}

// Timezone is a timezone's all data.
Expand All @@ -53,14 +73,13 @@ message Timezone {

message Timezones {
repeated Timezone timezones = 1;
bool reduced = 2; // Reduced data will toggle neighbor search as plan b
bool reduced = 2; // Reduced data will toggle neighbor search as plan b
string version = 3;
}

enum CompressMethod {
Unknown = 0;
Polyline =
1; // https://developers.google.com/maps/documentation/utilities/polylinealgorithm
COMPRESS_METHOD_UNSPECIFIED = 0;
COMPRESS_METHOD_POLYLINE = 1; // https://developers.google.com/maps/documentation/utilities/polylinealgorithm
}

message CompressedPolygon {
Expand Down Expand Up @@ -92,8 +111,8 @@ message PreindexTimezone {

// PreindexTimezones is all preindex timezone's dumps.
message PreindexTimezones {
int32 idxZoom = 1; // which zoom value the tiles generated
int32 aggZoom = 2; // which zoom value the tiles merge up with.
int32 idx_zoom = 1; // which zoom value the tiles generated
int32 agg_zoom = 2; // which zoom value the tiles merge up with.
repeated PreindexTimezone keys = 3;
string version = 4;
}
8 changes: 6 additions & 2 deletions src/gen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use prost::Message;

pub mod pb;
pub use pb::*;
pub mod tzf {
pub mod v1 {
include!("tzf.v1.rs");
}
}
pub use tzf::v1::*;

impl TryFrom<Vec<u8>> for Timezones {
type Error = anyhow::Error;
Expand Down
65 changes: 34 additions & 31 deletions src/gen/pb.rs → src/gen/tzf.v1.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/// Basic Point data define.
// @generated
// This file is @generated by prost-build.
/// Basic point data define.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Point {
#[prost(float, tag = "1")]
#[prost(float, tag="1")]
pub lng: f32,
#[prost(float, tag = "2")]
#[prost(float, tag="2")]
pub lat: f32,
}
/// Define a polygon, mostly based on GeoJSON's Polygon define.
Expand Down Expand Up @@ -41,57 +43,57 @@ pub struct Point {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Polygon {
/// define the "exterior ring"
#[prost(message, repeated, tag = "1")]
#[prost(message, repeated, tag="1")]
pub points: ::prost::alloc::vec::Vec<Point>,
/// define the "interior rings" as holes
#[prost(message, repeated, tag = "2")]
#[prost(message, repeated, tag="2")]
pub holes: ::prost::alloc::vec::Vec<Polygon>,
}
/// Timezone is a timezone's all data.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Timezone {
#[prost(message, repeated, tag = "1")]
#[prost(message, repeated, tag="1")]
pub polygons: ::prost::alloc::vec::Vec<Polygon>,
#[prost(string, tag = "2")]
#[prost(string, tag="2")]
pub name: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Timezones {
#[prost(message, repeated, tag = "1")]
#[prost(message, repeated, tag="1")]
pub timezones: ::prost::alloc::vec::Vec<Timezone>,
/// Reduced data will toggle neighbor search as plan b
#[prost(bool, tag = "2")]
#[prost(bool, tag="2")]
pub reduced: bool,
#[prost(string, tag = "3")]
#[prost(string, tag="3")]
pub version: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompressedPolygon {
#[prost(bytes = "vec", tag = "1")]
#[prost(bytes="vec", tag="1")]
pub points: ::prost::alloc::vec::Vec<u8>,
#[prost(message, repeated, tag = "2")]
#[prost(message, repeated, tag="2")]
pub holes: ::prost::alloc::vec::Vec<CompressedPolygon>,
}
/// CompressedTimezonesItem designed for binary file as small as possible.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompressedTimezone {
#[prost(message, repeated, tag = "1")]
#[prost(message, repeated, tag="1")]
pub data: ::prost::alloc::vec::Vec<CompressedPolygon>,
#[prost(string, tag = "2")]
#[prost(string, tag="2")]
pub name: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompressedTimezones {
#[prost(enumeration = "CompressMethod", tag = "1")]
#[prost(enumeration="CompressMethod", tag="1")]
pub method: i32,
#[prost(message, repeated, tag = "2")]
#[prost(message, repeated, tag="2")]
pub timezones: ::prost::alloc::vec::Vec<CompressedTimezone>,
#[prost(string, tag = "3")]
#[prost(string, tag="3")]
pub version: ::prost::alloc::string::String,
}
/// PreindexTimezone tile item.
Expand All @@ -100,34 +102,34 @@ pub struct CompressedTimezones {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PreindexTimezone {
#[prost(string, tag = "1")]
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(int32, tag = "2")]
#[prost(int32, tag="2")]
pub x: i32,
#[prost(int32, tag = "3")]
#[prost(int32, tag="3")]
pub y: i32,
#[prost(int32, tag = "4")]
#[prost(int32, tag="4")]
pub z: i32,
}
/// PreindexTimezones is all preindex timezone's dumps.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PreindexTimezones {
/// which zoom value the tiles generated
#[prost(int32, tag = "1")]
#[prost(int32, tag="1")]
pub idx_zoom: i32,
/// which zoom value the tiles merge up with.
#[prost(int32, tag = "2")]
#[prost(int32, tag="2")]
pub agg_zoom: i32,
#[prost(message, repeated, tag = "3")]
#[prost(message, repeated, tag="3")]
pub keys: ::prost::alloc::vec::Vec<PreindexTimezone>,
#[prost(string, tag = "4")]
#[prost(string, tag="4")]
pub version: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum CompressMethod {
Unknown = 0,
Unspecified = 0,
/// <https://developers.google.com/maps/documentation/utilities/polylinealgorithm>
Polyline = 1,
}
Expand All @@ -138,16 +140,17 @@ impl CompressMethod {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
CompressMethod::Unknown => "Unknown",
CompressMethod::Polyline => "Polyline",
CompressMethod::Unspecified => "COMPRESS_METHOD_UNSPECIFIED",
CompressMethod::Polyline => "COMPRESS_METHOD_POLYLINE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"Unknown" => Some(Self::Unknown),
"Polyline" => Some(Self::Polyline),
"COMPRESS_METHOD_UNSPECIFIED" => Some(Self::Unspecified),
"COMPRESS_METHOD_POLYLINE" => Some(Self::Polyline),
_ => None,
}
}
}
// @@protoc_insertion_point(module)

0 comments on commit 1ff7e52

Please sign in to comment.