#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PingRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PingResponse {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CommandRetryOptions {
#[prost(uint32, optional, tag = "1")]
pub timeout_ms: ::core::option::Option<u32>,
#[prost(uint32, optional, tag = "2")]
pub retry_interval_ms: ::core::option::Option<u32>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LaunchBrowserCommand {
#[prost(enumeration = "BrowserKind", tag = "1")]
pub browser_kind: i32,
#[prost(string, optional, tag = "2")]
pub browser_binary: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BrowserLaunchedEvent {
#[prost(enumeration = "BrowserKind", tag = "1")]
pub browser_kind: i32,
#[prost(string, tag = "2")]
pub browser: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub user_data_dir: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub initial_tab_session_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LaunchChromeCommand {
#[prost(string, optional, tag = "1")]
pub chrome_binary: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChromeLaunchedEvent {
#[prost(string, tag = "1")]
pub browser: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub note: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub cdp_websocket_url: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub user_data_dir: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub initial_tab_session_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NavigateTabCommand {
#[prost(string, tag = "1")]
pub url: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClickElementCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CountElementsCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HighlightElementsCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(uint32, optional, tag = "2")]
pub duration_ms: ::core::option::Option<u32>,
#[prost(message, optional, tag = "3")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FocusElementCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FillElementCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub value: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HoverElementCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PressKeyCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub key: ::prost::alloc::string::String,
#[prost(string, optional, tag = "3")]
pub text: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, optional, tag = "4")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetTextContentCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetInnerTextCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WaitForSelectorCommand {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(bool, optional, tag = "2")]
pub visible: ::core::option::Option<bool>,
#[prost(message, optional, tag = "3")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabNavigatedEvent {
#[prost(string, tag = "1")]
pub url: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ChromiumBidiInjectionEvent {
#[prost(string, tag = "1")]
pub note: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub bidi_session_id: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub mapper_target_id: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub mapper_session_id: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub package_version: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ElementClickedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub note: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub bidi_session_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ElementCountedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub count: u32,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ElementsHighlightedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub count: u32,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ElementFocusedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ElementFilledEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub value: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ElementHoveredEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyPressedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub key: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TextContentResolvedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InnerTextResolvedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SelectorWaitSatisfiedEvent {
#[prost(string, tag = "1")]
pub css_selector: ::prost::alloc::string::String,
#[prost(bool, tag = "2")]
pub visible: bool,
#[prost(string, tag = "3")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum BrowserKind {
Unspecified = 0,
Chromium = 1,
Firefox = 2,
}
impl BrowserKind {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "BROWSER_KIND_UNSPECIFIED",
Self::Chromium => "BROWSER_KIND_CHROMIUM",
Self::Firefox => "BROWSER_KIND_FIREFOX",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"BROWSER_KIND_UNSPECIFIED" => Some(Self::Unspecified),
"BROWSER_KIND_CHROMIUM" => Some(Self::Chromium),
"BROWSER_KIND_FIREFOX" => Some(Self::Firefox),
_ => None,
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BrowserSessionCommand {
#[prost(oneof = "browser_session_command::Command", tags = "1, 2, 3, 4, 5")]
pub command: ::core::option::Option<browser_session_command::Command>,
}
pub mod browser_session_command {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Command {
#[prost(message, tag = "1")]
LaunchChrome(super::LaunchChromeCommand),
#[prost(message, tag = "2")]
OpenTab(super::OpenTabCommand),
#[prost(message, tag = "3")]
Ping(super::SessionPingCommand),
#[prost(message, tag = "4")]
Close(super::CloseBrowserSessionCommand),
#[prost(message, tag = "5")]
LaunchBrowser(super::LaunchBrowserCommand),
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct OpenTabCommand {
#[prost(message, optional, tag = "1")]
pub retry_options: ::core::option::Option<CommandRetryOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SessionPingCommand {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CloseBrowserSessionCommand {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BrowserSessionEvent {
#[prost(string, tag = "1")]
pub session_id: ::prost::alloc::string::String,
#[prost(oneof = "browser_session_event::Event", tags = "2, 3, 4, 5, 6, 7")]
pub event: ::core::option::Option<browser_session_event::Event>,
}
pub mod browser_session_event {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Event {
#[prost(message, tag = "2")]
ChromeLaunched(super::ChromeLaunchedEvent),
#[prost(message, tag = "3")]
TabOpened(super::TabOpenedEvent),
#[prost(message, tag = "4")]
Pong(super::SessionPongEvent),
#[prost(message, tag = "5")]
Closed(super::BrowserSessionClosedEvent),
#[prost(message, tag = "6")]
Error(super::BrowserSessionErrorEvent),
#[prost(message, tag = "7")]
BrowserLaunched(super::BrowserLaunchedEvent),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabOpenedEvent {
#[prost(string, tag = "1")]
pub tab_session_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SessionPongEvent {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BrowserSessionClosedEvent {
#[prost(string, tag = "1")]
pub reason: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BrowserSessionErrorEvent {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabSessionCommand {
#[prost(string, tag = "1")]
pub browser_session_id: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub tab_session_id: ::prost::alloc::string::String,
#[prost(
oneof = "tab_session_command::Command",
tags = "3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"
)]
pub command: ::core::option::Option<tab_session_command::Command>,
}
pub mod tab_session_command {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Command {
#[prost(message, tag = "3")]
Ping(super::TabSessionPingCommand),
#[prost(message, tag = "4")]
Close(super::CloseTabSessionCommand),
#[prost(message, tag = "5")]
Navigate(super::NavigateTabCommand),
#[prost(message, tag = "6")]
ClickElement(super::ClickElementCommand),
#[prost(message, tag = "7")]
CountElements(super::CountElementsCommand),
#[prost(message, tag = "8")]
HighlightElements(super::HighlightElementsCommand),
#[prost(message, tag = "9")]
FocusElement(super::FocusElementCommand),
#[prost(message, tag = "10")]
FillElement(super::FillElementCommand),
#[prost(message, tag = "11")]
HoverElement(super::HoverElementCommand),
#[prost(message, tag = "12")]
PressKey(super::PressKeyCommand),
#[prost(message, tag = "13")]
GetTextContent(super::GetTextContentCommand),
#[prost(message, tag = "14")]
GetInnerText(super::GetInnerTextCommand),
#[prost(message, tag = "15")]
WaitForSelector(super::WaitForSelectorCommand),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabSessionPingCommand {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CloseTabSessionCommand {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabSessionEvent {
#[prost(string, tag = "1")]
pub tab_session_id: ::prost::alloc::string::String,
#[prost(
oneof = "tab_session_event::Event",
tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17"
)]
pub event: ::core::option::Option<tab_session_event::Event>,
}
pub mod tab_session_event {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Event {
#[prost(message, tag = "2")]
Attached(super::TabSessionAttachedEvent),
#[prost(message, tag = "3")]
Pong(super::TabSessionPongEvent),
#[prost(message, tag = "4")]
Closed(super::TabSessionClosedEvent),
#[prost(message, tag = "5")]
Error(super::TabSessionErrorEvent),
#[prost(message, tag = "6")]
Navigated(super::TabNavigatedEvent),
#[prost(message, tag = "7")]
ChromiumBidiInjection(super::ChromiumBidiInjectionEvent),
#[prost(message, tag = "8")]
ElementClicked(super::ElementClickedEvent),
#[prost(message, tag = "9")]
ElementCounted(super::ElementCountedEvent),
#[prost(message, tag = "10")]
ElementsHighlighted(super::ElementsHighlightedEvent),
#[prost(message, tag = "11")]
ElementFocused(super::ElementFocusedEvent),
#[prost(message, tag = "12")]
ElementFilled(super::ElementFilledEvent),
#[prost(message, tag = "13")]
ElementHovered(super::ElementHoveredEvent),
#[prost(message, tag = "14")]
KeyPressed(super::KeyPressedEvent),
#[prost(message, tag = "15")]
TextContentResolved(super::TextContentResolvedEvent),
#[prost(message, tag = "16")]
InnerTextResolved(super::InnerTextResolvedEvent),
#[prost(message, tag = "17")]
SelectorWaitSatisfied(super::SelectorWaitSatisfiedEvent),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabSessionAttachedEvent {
#[prost(string, tag = "1")]
pub note: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabSessionPongEvent {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabSessionClosedEvent {
#[prost(string, tag = "1")]
pub reason: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TabSessionErrorEvent {
#[prost(string, tag = "1")]
pub message: ::prost::alloc::string::String,
}
pub mod engine_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct EngineServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl EngineServiceClient<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> EngineServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::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,
) -> EngineServiceClient<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> + std::marker::Send + std::marker::Sync,
{
EngineServiceClient::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 ping(
&mut self,
request: impl tonic::IntoRequest<super::PingRequest>,
) -> std::result::Result<tonic::Response<super::PingResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/allwright.engine.v1.EngineService/Ping",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("allwright.engine.v1.EngineService", "Ping"));
self.inner.unary(req, path, codec).await
}
pub async fn browser_session(
&mut self,
request: impl tonic::IntoStreamingRequest<
Message = super::BrowserSessionCommand,
>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::BrowserSessionEvent>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/allwright.engine.v1.EngineService/BrowserSession",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"allwright.engine.v1.EngineService",
"BrowserSession",
),
);
self.inner.streaming(req, path, codec).await
}
pub async fn tab_session(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::TabSessionCommand>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::TabSessionEvent>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/allwright.engine.v1.EngineService/TabSession",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(
GrpcMethod::new("allwright.engine.v1.EngineService", "TabSession"),
);
self.inner.streaming(req, path, codec).await
}
}
}
pub mod engine_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait EngineService: std::marker::Send + std::marker::Sync + 'static {
async fn ping(
&self,
request: tonic::Request<super::PingRequest>,
) -> std::result::Result<tonic::Response<super::PingResponse>, tonic::Status>;
type BrowserSessionStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::BrowserSessionEvent, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn browser_session(
&self,
request: tonic::Request<tonic::Streaming<super::BrowserSessionCommand>>,
) -> std::result::Result<
tonic::Response<Self::BrowserSessionStream>,
tonic::Status,
>;
type TabSessionStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::TabSessionEvent, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn tab_session(
&self,
request: tonic::Request<tonic::Streaming<super::TabSessionCommand>>,
) -> std::result::Result<tonic::Response<Self::TabSessionStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct EngineServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> EngineServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for EngineServiceServer<T>
where
T: EngineService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/allwright.engine.v1.EngineService/Ping" => {
#[allow(non_camel_case_types)]
struct PingSvc<T: EngineService>(pub Arc<T>);
impl<
T: EngineService,
> tonic::server::UnaryService<super::PingRequest> for PingSvc<T> {
type Response = super::PingResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::PingRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as EngineService>::ping(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = PingSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/allwright.engine.v1.EngineService/BrowserSession" => {
#[allow(non_camel_case_types)]
struct BrowserSessionSvc<T: EngineService>(pub Arc<T>);
impl<
T: EngineService,
> tonic::server::StreamingService<super::BrowserSessionCommand>
for BrowserSessionSvc<T> {
type Response = super::BrowserSessionEvent;
type ResponseStream = T::BrowserSessionStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::BrowserSessionCommand>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as EngineService>::browser_session(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = BrowserSessionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/allwright.engine.v1.EngineService/TabSession" => {
#[allow(non_camel_case_types)]
struct TabSessionSvc<T: EngineService>(pub Arc<T>);
impl<
T: EngineService,
> tonic::server::StreamingService<super::TabSessionCommand>
for TabSessionSvc<T> {
type Response = super::TabSessionEvent;
type ResponseStream = T::TabSessionStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::TabSessionCommand>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as EngineService>::tab_session(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = TabSessionSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(empty_body());
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for EngineServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "allwright.engine.v1.EngineService";
impl<T> tonic::server::NamedService for EngineServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}