#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Polygon {
#[prost(message, repeated, tag = "1")]
pub vertices: ::prost::alloc::vec::Vec<Vertex>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Vertex {
#[prost(int64, tag = "1")]
pub x: i64,
#[prost(int64, tag = "2")]
pub y: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TextAnnotation {
#[prost(int64, tag = "1")]
pub width: i64,
#[prost(int64, tag = "2")]
pub height: i64,
#[prost(message, repeated, tag = "3")]
pub blocks: ::prost::alloc::vec::Vec<Block>,
#[prost(message, repeated, tag = "4")]
pub entities: ::prost::alloc::vec::Vec<Entity>,
#[prost(message, repeated, tag = "5")]
pub tables: ::prost::alloc::vec::Vec<Table>,
#[prost(string, tag = "6")]
pub full_text: ::prost::alloc::string::String,
#[prost(enumeration = "Angle", tag = "7")]
pub rotate: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entity {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Block {
#[prost(message, optional, tag = "1")]
pub bounding_box: ::core::option::Option<Polygon>,
#[prost(message, repeated, tag = "2")]
pub lines: ::prost::alloc::vec::Vec<Line>,
#[prost(message, repeated, tag = "3")]
pub languages: ::prost::alloc::vec::Vec<block::DetectedLanguage>,
#[prost(message, repeated, tag = "4")]
pub text_segments: ::prost::alloc::vec::Vec<TextSegments>,
}
pub mod block {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DetectedLanguage {
#[prost(string, tag = "1")]
pub language_code: ::prost::alloc::string::String,
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Line {
#[prost(message, optional, tag = "1")]
pub bounding_box: ::core::option::Option<Polygon>,
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
pub words: ::prost::alloc::vec::Vec<Word>,
#[prost(message, repeated, tag = "4")]
pub text_segments: ::prost::alloc::vec::Vec<TextSegments>,
#[prost(enumeration = "Angle", tag = "5")]
pub orientation: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Word {
#[prost(message, optional, tag = "1")]
pub bounding_box: ::core::option::Option<Polygon>,
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
#[prost(int64, tag = "3")]
pub entity_index: i64,
#[prost(message, repeated, tag = "4")]
pub text_segments: ::prost::alloc::vec::Vec<TextSegments>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TextSegments {
#[prost(int64, tag = "1")]
pub start_index: i64,
#[prost(int64, tag = "2")]
pub length: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Table {
#[prost(message, optional, tag = "1")]
pub bounding_box: ::core::option::Option<Polygon>,
#[prost(int64, tag = "2")]
pub row_count: i64,
#[prost(int64, tag = "3")]
pub column_count: i64,
#[prost(message, repeated, tag = "4")]
pub cells: ::prost::alloc::vec::Vec<TableCell>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableCell {
#[prost(message, optional, tag = "1")]
pub bounding_box: ::core::option::Option<Polygon>,
#[prost(int64, tag = "2")]
pub row_index: i64,
#[prost(int64, tag = "3")]
pub column_index: i64,
#[prost(int64, tag = "4")]
pub column_span: i64,
#[prost(int64, tag = "5")]
pub row_span: i64,
#[prost(string, tag = "6")]
pub text: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "7")]
pub text_segments: ::prost::alloc::vec::Vec<TextSegments>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Angle {
Unspecified = 0,
Angle0 = 1,
Angle90 = 2,
Angle180 = 3,
Angle270 = 4,
}
impl Angle {
pub fn as_str_name(&self) -> &'static str {
match self {
Angle::Unspecified => "ANGLE_UNSPECIFIED",
Angle::Angle0 => "ANGLE_0",
Angle::Angle90 => "ANGLE_90",
Angle::Angle180 => "ANGLE_180",
Angle::Angle270 => "ANGLE_270",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ANGLE_UNSPECIFIED" => Some(Self::Unspecified),
"ANGLE_0" => Some(Self::Angle0),
"ANGLE_90" => Some(Self::Angle90),
"ANGLE_180" => Some(Self::Angle180),
"ANGLE_270" => Some(Self::Angle270),
_ => None,
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RecognizeTextRequest {
#[prost(string, tag = "2")]
pub mime_type: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "3")]
pub language_codes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "4")]
pub model: ::prost::alloc::string::String,
#[prost(oneof = "recognize_text_request::Source", tags = "1")]
pub source: ::core::option::Option<recognize_text_request::Source>,
}
pub mod recognize_text_request {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Source {
#[prost(bytes, tag = "1")]
Content(::prost::alloc::vec::Vec<u8>),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RecognizeTextResponse {
#[prost(message, optional, tag = "1")]
pub text_annotation: ::core::option::Option<TextAnnotation>,
#[prost(int64, tag = "2")]
pub page: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRecognitionRequest {
#[prost(string, tag = "1")]
pub operation_id: ::prost::alloc::string::String,
}
pub mod text_recognition_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct TextRecognitionServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl TextRecognitionServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> TextRecognitionServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> TextRecognitionServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
TextRecognitionServiceClient::new(
InterceptedService::new(inner, interceptor),
)
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn recognize(
&mut self,
request: impl tonic::IntoRequest<super::RecognizeTextRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::RecognizeTextResponse>>,
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(
"/yandex.cloud.ai.ocr.v1.TextRecognitionService/Recognize",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"yandex.cloud.ai.ocr.v1.TextRecognitionService",
"Recognize",
),
);
self.inner.server_streaming(req, path, codec).await
}
}
}
pub mod text_recognition_async_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct TextRecognitionAsyncServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl TextRecognitionAsyncServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> TextRecognitionAsyncServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> TextRecognitionAsyncServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
TextRecognitionAsyncServiceClient::new(
InterceptedService::new(inner, interceptor),
)
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn recognize(
&mut self,
request: impl tonic::IntoRequest<super::RecognizeTextRequest>,
) -> std::result::Result<
tonic::Response<super::super::super::super::operation::Operation>,
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(
"/yandex.cloud.ai.ocr.v1.TextRecognitionAsyncService/Recognize",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"yandex.cloud.ai.ocr.v1.TextRecognitionAsyncService",
"Recognize",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn get_recognition(
&mut self,
request: impl tonic::IntoRequest<super::GetRecognitionRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::RecognizeTextResponse>>,
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(
"/yandex.cloud.ai.ocr.v1.TextRecognitionAsyncService/GetRecognition",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"yandex.cloud.ai.ocr.v1.TextRecognitionAsyncService",
"GetRecognition",
),
);
self.inner.server_streaming(req, path, codec).await
}
}
}