// This file is @generated by prost-build.
/// The payload data from network layer
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Data {
    /// The raw payload data
    #[prost(bytes = "vec", tag = "1")]
    pub data: ::prost::alloc::vec::Vec<u8>,
    /// Indicates whether this is the last data frame in the current direction.
    /// The external processor should still respond to this message even
    /// if there is no more data expected in this direction.
    #[prost(bool, tag = "2")]
    pub end_of_stream: bool,
}
/// ProcessingRequest contains data sent from Envoy to the external processing server.
/// Each request contains either read data (from client) or write data (to client)
/// along with optional metadata.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProcessingRequest {
    /// ReadData contains the network data intercepted in the request path (client to server).
    /// This is sent to the external processor when data arrives from the downstream client.
    /// If this is set, write_data should not be set.
    #[prost(message, optional, tag = "1")]
    pub read_data: ::core::option::Option<Data>,
    /// WriteData contains the network data intercepted in the response path (server to client).
    /// This is sent to the external processor when data arrives from the upstream server.
    /// If this is set, read_data should not be set.
    #[prost(message, optional, tag = "2")]
    pub write_data: ::core::option::Option<Data>,
    /// Optional metadata associated with the request.
    /// This can include connection properties, filter configuration, and any other
    /// contextual information that might be useful for processing decisions.
    ///
    /// The metadata is not automatically propagated from request to response.
    /// The external processor must include any needed metadata in its response.
    #[prost(message, optional, tag = "3")]
    pub metadata: ::core::option::Option<
        super::super::super::config::core::v3::Metadata,
    >,
}
/// ProcessingResponse contains the response from the external processing server to Envoy.
/// Each response corresponds to a ProcessingRequest and indicates how the network
/// traffic should be handled.
/// \[\#next-free-field: 6\]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProcessingResponse {
    /// The processed ReadData containing potentially modified data for the request path.
    /// This should be sent in response to a ProcessingRequest with read_data, and the
    /// previous data in ProcessingRequest will be replaced by the new data in Envoy's data plane.
    /// If this is set, write_data should not be set.
    #[prost(message, optional, tag = "1")]
    pub read_data: ::core::option::Option<Data>,
    /// The processed WriteData containing potentially modified data for the response path.
    /// This should be sent in response to a ProcessingRequest with write_data, and the
    /// previous data in ProcessingRequest will be replaced by the new data in Envoy's data plane.
    /// If this is set, read_data should not be set.
    #[prost(message, optional, tag = "2")]
    pub write_data: ::core::option::Option<Data>,
    /// Indicates whether the data was modified or not.
    /// This is mandatory and tells Envoy whether to use the original or modified data.
    #[prost(enumeration = "processing_response::DataProcessedStatus", tag = "3")]
    pub data_processing_status: i32,
    /// Optional: Determines the connection behavior after processing.
    /// If not specified, CONTINUE is assumed, and the connection proceeds normally.
    /// Use CLOSE or CLOSE_RST to terminate the connection based on processing results.
    #[prost(enumeration = "processing_response::ConnectionStatus", tag = "4")]
    pub connection_status: i32,
    /// Optional metadata associated with the request.
    /// This can include connection properties, filter configuration, and any other
    /// contextual information that might be useful for processing decisions.
    ///
    /// The metadata is not automatically propagated from request to response.
    /// The external processor must include any needed metadata in its response.
    #[prost(message, optional, tag = "5")]
    pub dynamic_metadata: ::core::option::Option<
        super::super::super::super::google::protobuf::Struct,
    >,
}
/// Nested message and enum types in `ProcessingResponse`.
pub mod processing_response {
    /// DataProcessedStatus indicates whether the data was modified by the external processor.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum DataProcessedStatus {
        /// The data processed status is unknown.
        Unknown = 0,
        /// The data remains unchanged. Envoy will use the original data.
        /// This is useful when the processor only wants to inspect but not modify the traffic.
        Unmodified = 1,
        /// The data has been modified. Envoy will use the modified data provided in the response.
        /// This allows the processor to transform the network traffic as needed.
        Modified = 2,
    }
    impl DataProcessedStatus {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unknown => "UNKNOWN",
                Self::Unmodified => "UNMODIFIED",
                Self::Modified => "MODIFIED",
            }
        }
        /// 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),
                "UNMODIFIED" => Some(Self::Unmodified),
                "MODIFIED" => Some(Self::Modified),
                _ => None,
            }
        }
    }
    /// ConnectionStatus determines what happens to the connection after processing.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum ConnectionStatus {
        /// Continue normal processing of the connection.
        /// This is the default behavior and allows traffic to flow normally.
        Continue = 0,
        /// Close the connection with normal TCP FIN.
        /// This allows for clean connection termination with a normal close sequence.
        /// Any buffered data will be sent before closing.
        Close = 1,
        /// Immediately reset the connection with TCP RST.
        /// This forcibly terminates the connection without a clean shutdown,
        /// discarding any buffered data. Use this for security-critical situations
        /// or when immediate termination is required.
        CloseRst = 2,
    }
    impl ConnectionStatus {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Continue => "CONTINUE",
                Self::Close => "CLOSE",
                Self::CloseRst => "CLOSE_RST",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "CONTINUE" => Some(Self::Continue),
                "CLOSE" => Some(Self::Close),
                "CLOSE_RST" => Some(Self::CloseRst),
                _ => None,
            }
        }
    }
}
/// Generated client implementations.
pub mod network_external_processor_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// NetworkExternalProcessor service defines the contract between Envoy and
    /// external processing servers for L4 network traffic.
    #[derive(Debug, Clone)]
    pub struct NetworkExternalProcessorClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl<T> NetworkExternalProcessorClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        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,
        ) -> NetworkExternalProcessorClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            NetworkExternalProcessorClient::new(
                InterceptedService::new(inner, interceptor),
            )
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Process establishes a bidirectional stream between Envoy and the external
        /// processing server. Envoy sends ProcessingRequests containing network data
        /// and the server responds with ProcessingResponses containing processing
        /// decisions and potentially modified data.
        ///
        /// The server should handle processing timeout properly to avoid blocking
        /// network traffic for extended periods. Any uncaught exceptions will
        /// be treated as errors and will terminate the stream.
        ///
        /// Implementation note: The server should process requests in the order
        /// they are received to maintain proper sequencing of network traffic.
        pub async fn process(
            &mut self,
            request: impl tonic::IntoStreamingRequest<Message = super::ProcessingRequest>,
        ) -> std::result::Result<
            tonic::Response<tonic::codec::Streaming<super::ProcessingResponse>>,
            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(
                "/envoy.service.network_ext_proc.v3.NetworkExternalProcessor/Process",
            );
            let mut req = request.into_streaming_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "envoy.service.network_ext_proc.v3.NetworkExternalProcessor",
                        "Process",
                    ),
                );
            self.inner.streaming(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod network_external_processor_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with NetworkExternalProcessorServer.
    #[async_trait]
    pub trait NetworkExternalProcessor: std::marker::Send + std::marker::Sync + 'static {
        /// Server streaming response type for the Process method.
        type ProcessStream: tonic::codegen::tokio_stream::Stream<
                Item = std::result::Result<super::ProcessingResponse, tonic::Status>,
            >
            + std::marker::Send
            + 'static;
        /// Process establishes a bidirectional stream between Envoy and the external
        /// processing server. Envoy sends ProcessingRequests containing network data
        /// and the server responds with ProcessingResponses containing processing
        /// decisions and potentially modified data.
        ///
        /// The server should handle processing timeout properly to avoid blocking
        /// network traffic for extended periods. Any uncaught exceptions will
        /// be treated as errors and will terminate the stream.
        ///
        /// Implementation note: The server should process requests in the order
        /// they are received to maintain proper sequencing of network traffic.
        async fn process(
            &self,
            request: tonic::Request<tonic::Streaming<super::ProcessingRequest>>,
        ) -> std::result::Result<tonic::Response<Self::ProcessStream>, tonic::Status>;
    }
    /// NetworkExternalProcessor service defines the contract between Envoy and
    /// external processing servers for L4 network traffic.
    #[derive(Debug)]
    pub struct NetworkExternalProcessorServer<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> NetworkExternalProcessorServer<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)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[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 NetworkExternalProcessorServer<T>
    where
        T: NetworkExternalProcessor,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        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() {
                "/envoy.service.network_ext_proc.v3.NetworkExternalProcessor/Process" => {
                    #[allow(non_camel_case_types)]
                    struct ProcessSvc<T: NetworkExternalProcessor>(pub Arc<T>);
                    impl<
                        T: NetworkExternalProcessor,
                    > tonic::server::StreamingService<super::ProcessingRequest>
                    for ProcessSvc<T> {
                        type Response = super::ProcessingResponse;
                        type ResponseStream = T::ProcessStream;
                        type Future = BoxFuture<
                            tonic::Response<Self::ResponseStream>,
                            tonic::Status,
                        >;
                        fn call(
                            &mut self,
                            request: tonic::Request<
                                tonic::Streaming<super::ProcessingRequest>,
                            >,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as NetworkExternalProcessor>::process(&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 = ProcessSvc(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(
                            tonic::body::Body::default(),
                        );
                        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 NetworkExternalProcessorServer<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,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "envoy.service.network_ext_proc.v3.NetworkExternalProcessor";
    impl<T> tonic::server::NamedService for NetworkExternalProcessorServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}
