#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartScale {
#[prost(enumeration = "chart_scale::ChartScaleKind", tag = "1")]
pub kind: i32,
#[prost(message, optional, tag = "2")]
pub range_start: ::core::option::Option<i32>,
#[prost(message, optional, tag = "3")]
pub range_end: ::core::option::Option<i32>,
#[prost(bool, tag = "7")]
pub no_boundaries_offset: bool,
#[prost(message, optional, tag = "8")]
pub inner_padding: ::core::option::Option<f32>,
#[prost(message, optional, tag = "9")]
pub outer_padding: ::core::option::Option<f32>,
#[prost(oneof = "chart_scale::Domain", tags = "4, 5")]
pub domain: ::core::option::Option<chart_scale::Domain>,
}
pub mod chart_scale {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ChartScaleKind {
UnspecifiedScale = 0,
Linear = 1,
Band = 2,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Domain {
#[prost(message, tag = "4")]
DomainNumeric(super::DomainNumeric),
#[prost(message, tag = "5")]
DomainCategories(super::DomainCategories),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DomainNumeric {
#[prost(float, tag = "1")]
pub start: f32,
#[prost(float, tag = "2")]
pub end: f32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DomainCategories {
#[prost(string, repeated, tag = "1")]
pub categories: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartSizes {
#[prost(message, optional, tag = "1")]
pub width: ::core::option::Option<i32>,
#[prost(message, optional, tag = "2")]
pub height: ::core::option::Option<i32>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartMargins {
#[prost(message, optional, tag = "1")]
pub margin_top: ::core::option::Option<i32>,
#[prost(message, optional, tag = "2")]
pub margin_bottom: ::core::option::Option<i32>,
#[prost(message, optional, tag = "3")]
pub margin_left: ::core::option::Option<i32>,
#[prost(message, optional, tag = "4")]
pub margin_right: ::core::option::Option<i32>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartAxes {
#[prost(message, optional, tag = "1")]
pub axis_top: ::core::option::Option<ChartScale>,
#[prost(string, tag = "2")]
pub axis_top_label: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub axis_bottom: ::core::option::Option<ChartScale>,
#[prost(string, tag = "4")]
pub axis_bottom_label: ::prost::alloc::string::String,
#[prost(message, optional, tag = "5")]
pub axis_left: ::core::option::Option<ChartScale>,
#[prost(string, tag = "6")]
pub axis_left_label: ::prost::alloc::string::String,
#[prost(message, optional, tag = "7")]
pub axis_right: ::core::option::Option<ChartScale>,
#[prost(string, tag = "8")]
pub axis_right_label: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartElementColor {
#[prost(oneof = "chart_element_color::ColorValue", tags = "1, 2")]
pub color_value: ::core::option::Option<chart_element_color::ColorValue>,
}
pub mod chart_element_color {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Rgb {
#[prost(uint32, tag = "1")]
pub r: u32,
#[prost(uint32, tag = "2")]
pub g: u32,
#[prost(uint32, tag = "3")]
pub b: u32,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ColorValue {
#[prost(string, tag = "1")]
ColorHex(::prost::alloc::string::String),
#[prost(message, tag = "2")]
ColorRgb(Rgb),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartViewBarsValues {
#[prost(message, repeated, tag = "1")]
pub bars_datasets: ::prost::alloc::vec::Vec<chart_view_bars_values::BarsDataset>,
}
pub mod chart_view_bars_values {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartViewBarsColors {
#[prost(message, optional, tag = "1")]
pub fill: ::core::option::Option<super::ChartElementColor>,
#[prost(message, optional, tag = "2")]
pub stroke: ::core::option::Option<super::ChartElementColor>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BarsDataset {
#[prost(float, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<f32>,
#[prost(message, optional, tag = "2")]
pub colors: ::core::option::Option<ChartViewBarsColors>,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartViewPointsValues {
#[prost(message, repeated, tag = "1")]
pub points: ::prost::alloc::vec::Vec<chart_view_points_values::Point>,
}
pub mod chart_view_points_values {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Point {
#[prost(float, tag = "1")]
pub x: f32,
#[prost(float, tag = "2")]
pub y: f32,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartViewScalarValues {
#[prost(float, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<f32>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartView {
#[prost(enumeration = "chart_view::ChartViewKind", tag = "1")]
pub kind: i32,
#[prost(message, optional, tag = "5")]
pub colors: ::core::option::Option<ChartViewColors>,
#[prost(message, optional, tag = "6")]
pub bar_label_visible: ::core::option::Option<bool>,
#[prost(enumeration = "chart_view::ChartViewBarLabelPosition", tag = "7")]
pub bar_label_position: i32,
#[prost(message, optional, tag = "8")]
pub point_visible: ::core::option::Option<bool>,
#[prost(enumeration = "chart_view::ChartViewPointType", tag = "9")]
pub point_type: i32,
#[prost(message, optional, tag = "10")]
pub point_label_visible: ::core::option::Option<bool>,
#[prost(enumeration = "chart_view::ChartViewPointLabelPosition", tag = "11")]
pub point_label_position: i32,
#[prost(oneof = "chart_view::Values", tags = "2, 3, 4")]
pub values: ::core::option::Option<chart_view::Values>,
}
pub mod chart_view {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ChartViewKind {
UnspecifiedKind = 0,
Area = 1,
HorizontalBar = 2,
Line = 3,
Scatter = 4,
VerticalBar = 5,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ChartViewBarLabelPosition {
UnspecifiedBarLabelPosition = 0,
StartOutside = 1,
StartInside = 2,
Center = 3,
EndInside = 4,
EndOutside = 5,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ChartViewPointType {
UnspecifiedPointType = 0,
Circle = 1,
Square = 2,
X = 3,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ChartViewPointLabelPosition {
UnspecifiedPointLabelPosition = 0,
Top = 1,
TopRight = 2,
TopLeft = 3,
Left = 4,
Right = 5,
Bottom = 6,
BottomLeft = 7,
BottomRight = 8,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Values {
#[prost(message, tag = "2")]
ScalarValues(super::ChartViewScalarValues),
#[prost(message, tag = "3")]
PointsValues(super::ChartViewPointsValues),
#[prost(message, tag = "4")]
BarsValues(super::ChartViewBarsValues),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChartViewColors {
#[prost(message, optional, tag = "1")]
pub fill: ::core::option::Option<ChartElementColor>,
#[prost(message, optional, tag = "2")]
pub stroke: ::core::option::Option<ChartElementColor>,
#[prost(message, optional, tag = "3")]
pub point_fill: ::core::option::Option<ChartElementColor>,
#[prost(message, optional, tag = "4")]
pub point_stroke: ::core::option::Option<ChartElementColor>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RenderChartRequest {
#[prost(string, tag = "1")]
pub request_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub title: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub sizes: ::core::option::Option<ChartSizes>,
#[prost(message, optional, tag = "4")]
pub margins: ::core::option::Option<ChartMargins>,
#[prost(message, optional, tag = "5")]
pub axes: ::core::option::Option<ChartAxes>,
#[prost(message, repeated, tag = "6")]
pub views: ::prost::alloc::vec::Vec<ChartView>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RenderChartReply {
#[prost(string, tag = "1")]
pub request_id: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub chart_data: ::prost::alloc::vec::Vec<u8>,
}
#[doc = r" Generated client implementations."]
pub mod chart_renderer_client {
#![allow(unused_variables, dead_code, missing_docs)]
use tonic::codegen::*;
#[doc = " ChartRenderer represents a service that uses lc-render library to create charts."]
pub struct ChartRendererClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ChartRendererClient<tonic::transport::Channel> {
#[doc = r" Attempt to create a new client by connecting to a given endpoint."]
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ChartRendererClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
T::Error: Into<StdError>,
<T::ResponseBody as HttpBody>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
let inner = tonic::client::Grpc::with_interceptor(inner, interceptor);
Self { inner }
}
#[doc = " Render chart and return its raw bytes representation."]
pub async fn render_chart(
&mut self,
request: impl tonic::IntoRequest<super::RenderChartRequest>,
) -> Result<tonic::Response<super::RenderChartReply>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/render.ChartRenderer/RenderChart");
self.inner.unary(request.into_request(), path, codec).await
}
}
impl<T: Clone> Clone for ChartRendererClient<T> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
}
}
}
impl<T> std::fmt::Debug for ChartRendererClient<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ChartRendererClient {{ ... }}")
}
}
}
#[doc = r" Generated server implementations."]
pub mod chart_renderer_server {
#![allow(unused_variables, dead_code, missing_docs)]
use tonic::codegen::*;
#[doc = "Generated trait containing gRPC methods that should be implemented for use with ChartRendererServer."]
#[async_trait]
pub trait ChartRenderer: Send + Sync + 'static {
#[doc = " Render chart and return its raw bytes representation."]
async fn render_chart(
&self,
request: tonic::Request<super::RenderChartRequest>,
) -> Result<tonic::Response<super::RenderChartReply>, tonic::Status>;
}
#[doc = " ChartRenderer represents a service that uses lc-render library to create charts."]
#[derive(Debug)]
pub struct ChartRendererServer<T: ChartRenderer> {
inner: _Inner<T>,
}
struct _Inner<T>(Arc<T>, Option<tonic::Interceptor>);
impl<T: ChartRenderer> ChartRendererServer<T> {
pub fn new(inner: T) -> Self {
let inner = Arc::new(inner);
let inner = _Inner(inner, None);
Self { inner }
}
pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
let inner = Arc::new(inner);
let inner = _Inner(inner, Some(interceptor.into()));
Self { inner }
}
}
impl<T, B> Service<http::Request<B>> for ChartRendererServer<T>
where
T: ChartRenderer,
B: HttpBody + Send + Sync + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = Never;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/render.ChartRenderer/RenderChart" => {
#[allow(non_camel_case_types)]
struct RenderChartSvc<T: ChartRenderer>(pub Arc<T>);
impl<T: ChartRenderer> tonic::server::UnaryService<super::RenderChartRequest>
for RenderChartSvc<T>
{
type Response = super::RenderChartReply;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::RenderChartRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).render_chart(request).await };
Box::pin(fut)
}
}
let inner = self.inner.clone();
let fut = async move {
let interceptor = inner.1.clone();
let inner = inner.0;
let method = RenderChartSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = if let Some(interceptor) = interceptor {
tonic::server::Grpc::with_interceptor(codec, interceptor)
} else {
tonic::server::Grpc::new(codec)
};
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => Box::pin(async move {
Ok(http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(tonic::body::BoxBody::empty())
.unwrap())
}),
}
}
}
impl<T: ChartRenderer> Clone for ChartRendererServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self { inner }
}
}
impl<T: ChartRenderer> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone(), self.1.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: ChartRenderer> tonic::transport::NamedService for ChartRendererServer<T> {
const NAME: &'static str = "render.ChartRenderer";
}
}