#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteRequest {
#[prost(message, optional, tag = "1")]
pub target: ::core::option::Option<TargetDevice>,
#[prost(uint32, tag = "2")]
pub client_id: u32,
#[prost(message, repeated, tag = "3")]
pub updates: ::prost::alloc::vec::Vec<Update>,
#[prost(enumeration = "write_request::Atomicity", tag = "4")]
pub atomicity: i32,
#[prost(string, tag = "5")]
pub p4_name: ::prost::alloc::string::String,
}
pub mod write_request {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Atomicity {
ContinueOnError = 0,
RollbackOnError = 1,
DataplaneAtomic = 2,
}
impl Atomicity {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::ContinueOnError => "CONTINUE_ON_ERROR",
Self::RollbackOnError => "ROLLBACK_ON_ERROR",
Self::DataplaneAtomic => "DATAPLANE_ATOMIC",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"CONTINUE_ON_ERROR" => Some(Self::ContinueOnError),
"ROLLBACK_ON_ERROR" => Some(Self::RollbackOnError),
"DATAPLANE_ATOMIC" => Some(Self::DataplaneAtomic),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WriteResponse {
#[prost(message, repeated, tag = "1")]
pub status: ::prost::alloc::vec::Vec<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadRequest {
#[prost(message, optional, tag = "1")]
pub target: ::core::option::Option<TargetDevice>,
#[prost(uint32, tag = "2")]
pub client_id: u32,
#[prost(message, repeated, tag = "3")]
pub entities: ::prost::alloc::vec::Vec<Entity>,
#[prost(string, tag = "4")]
pub p4_name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadResponse {
#[prost(message, repeated, tag = "1")]
pub entities: ::prost::alloc::vec::Vec<Entity>,
#[prost(message, repeated, tag = "2")]
pub status: ::prost::alloc::vec::Vec<Error>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TargetDevice {
#[prost(uint32, tag = "1")]
pub device_id: u32,
#[prost(uint32, tag = "2")]
pub pipe_id: u32,
#[prost(uint32, tag = "3")]
pub direction: u32,
#[prost(uint32, tag = "4")]
pub prsr_id: u32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Update {
#[prost(enumeration = "update::Type", tag = "1")]
pub r#type: i32,
#[prost(message, optional, tag = "2")]
pub entity: ::core::option::Option<Entity>,
}
pub mod update {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Type {
Unspecified = 0,
Insert = 1,
Modify = 2,
ModifyInc = 3,
Delete = 4,
InsertOrModify = 5,
Reset = 6,
}
impl Type {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "UNSPECIFIED",
Self::Insert => "INSERT",
Self::Modify => "MODIFY",
Self::ModifyInc => "MODIFY_INC",
Self::Delete => "DELETE",
Self::InsertOrModify => "INSERT_OR_MODIFY",
Self::Reset => "RESET",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNSPECIFIED" => Some(Self::Unspecified),
"INSERT" => Some(Self::Insert),
"MODIFY" => Some(Self::Modify),
"MODIFY_INC" => Some(Self::ModifyInc),
"DELETE" => Some(Self::Delete),
"INSERT_OR_MODIFY" => Some(Self::InsertOrModify),
"RESET" => Some(Self::Reset),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entity {
#[prost(oneof = "entity::Entity", tags = "1, 2, 3, 4, 5, 6")]
pub entity: ::core::option::Option<entity::Entity>,
}
pub mod entity {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Entity {
#[prost(message, tag = "1")]
TableEntry(super::TableEntry),
#[prost(message, tag = "2")]
TableUsage(super::TableUsage),
#[prost(message, tag = "3")]
TableAttribute(super::TableAttribute),
#[prost(message, tag = "4")]
TableOperation(super::TableOperation),
#[prost(message, tag = "5")]
ObjectId(super::ObjectId),
#[prost(message, tag = "6")]
Handle(super::HandleId),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HandleId {
#[prost(uint32, tag = "1")]
pub table_id: u32,
#[prost(oneof = "handle_id::Value", tags = "2, 3")]
pub value: ::core::option::Option<handle_id::Value>,
}
pub mod handle_id {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
#[prost(message, tag = "2")]
Key(super::TableKey),
#[prost(uint32, tag = "3")]
HandleId(u32),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableEntry {
#[prost(uint32, tag = "1")]
pub table_id: u32,
#[prost(message, optional, tag = "3")]
pub data: ::core::option::Option<TableData>,
#[prost(bool, tag = "4")]
pub is_default_entry: bool,
#[deprecated]
#[prost(message, optional, tag = "5")]
pub table_read_flag: ::core::option::Option<TableReadFlag>,
#[deprecated]
#[prost(message, optional, tag = "6")]
pub table_mod_inc_flag: ::core::option::Option<TableModIncFlag>,
#[prost(message, optional, tag = "8")]
pub entry_tgt: ::core::option::Option<TargetDevice>,
#[prost(message, optional, tag = "9")]
pub table_flags: ::core::option::Option<TableFlags>,
#[prost(oneof = "table_entry::Value", tags = "2, 7")]
pub value: ::core::option::Option<table_entry::Value>,
}
pub mod table_entry {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
#[prost(message, tag = "2")]
Key(super::TableKey),
#[prost(uint32, tag = "7")]
HandleId(u32),
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TableUsage {
#[prost(uint32, tag = "1")]
pub table_id: u32,
#[prost(uint32, tag = "2")]
pub usage: u32,
#[deprecated]
#[prost(message, optional, tag = "3")]
pub table_read_flag: ::core::option::Option<TableReadFlag>,
#[prost(message, optional, tag = "4")]
pub table_flags: ::core::option::Option<TableFlags>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableAttribute {
#[prost(uint32, tag = "1")]
pub table_id: u32,
#[prost(oneof = "table_attribute::Attribute", tags = "2, 3, 4, 5, 6, 7, 8, 9")]
pub attribute: ::core::option::Option<table_attribute::Attribute>,
}
pub mod table_attribute {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Attribute {
#[prost(message, tag = "2")]
IdleTable(super::IdleTable),
#[prost(message, tag = "3")]
EntryScope(super::EntryScope),
#[prost(message, tag = "4")]
DynKeyMask(super::DynKeyMask),
#[prost(message, tag = "5")]
DynHashing(super::DynHashing),
#[prost(message, tag = "6")]
ByteCountAdj(super::ByteCountAdj),
#[prost(message, tag = "7")]
PortStatusNotify(super::PortStatusChg),
#[prost(message, tag = "8")]
IntvlMs(super::StatePullIntvl),
#[prost(message, tag = "9")]
PreDeviceConfig(super::PreDeviceConfig),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableOperation {
#[prost(uint32, tag = "1")]
pub table_id: u32,
#[prost(string, tag = "2")]
pub table_operations_type: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableData {
#[prost(uint32, tag = "1")]
pub action_id: u32,
#[prost(message, repeated, tag = "2")]
pub fields: ::prost::alloc::vec::Vec<DataField>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataField {
#[prost(uint32, tag = "1")]
pub field_id: u32,
#[prost(oneof = "data_field::Value", tags = "2, 3, 4, 5, 6, 7, 8, 9")]
pub value: ::core::option::Option<data_field::Value>,
}
pub mod data_field {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IntArray {
#[prost(uint32, repeated, tag = "1")]
pub val: ::prost::alloc::vec::Vec<u32>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BoolArray {
#[prost(bool, repeated, tag = "1")]
pub val: ::prost::alloc::vec::Vec<bool>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StrArray {
#[prost(string, repeated, tag = "1")]
pub val: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContainerArray {
#[prost(message, repeated, tag = "1")]
pub container: ::prost::alloc::vec::Vec<container_array::Container>,
}
pub mod container_array {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Container {
#[prost(message, repeated, tag = "1")]
pub val: ::prost::alloc::vec::Vec<super::super::DataField>,
}
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
#[prost(bytes, tag = "2")]
Stream(::prost::alloc::vec::Vec<u8>),
#[prost(float, tag = "3")]
FloatVal(f32),
#[prost(string, tag = "4")]
StrVal(::prost::alloc::string::String),
#[prost(message, tag = "5")]
IntArrVal(IntArray),
#[prost(message, tag = "6")]
BoolArrVal(BoolArray),
#[prost(message, tag = "7")]
ContainerArrVal(ContainerArray),
#[prost(bool, tag = "8")]
BoolVal(bool),
#[prost(message, tag = "9")]
StrArrVal(StrArray),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableKey {
#[prost(message, repeated, tag = "1")]
pub fields: ::prost::alloc::vec::Vec<KeyField>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyField {
#[prost(uint32, tag = "1")]
pub field_id: u32,
#[prost(oneof = "key_field::MatchType", tags = "2, 3, 4, 5, 6")]
pub match_type: ::core::option::Option<key_field::MatchType>,
}
pub mod key_field {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Exact {
#[prost(bytes = "vec", tag = "1")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Ternary {
#[prost(bytes = "vec", tag = "1")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub mask: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Lpm {
#[prost(bytes = "vec", tag = "1")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(int32, tag = "2")]
pub prefix_len: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Range {
#[prost(bytes = "vec", tag = "1")]
pub low: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub high: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Optional {
#[prost(bytes = "vec", tag = "1")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(bool, tag = "2")]
pub is_valid: bool,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum MatchType {
#[prost(message, tag = "2")]
Exact(Exact),
#[prost(message, tag = "3")]
Ternary(Ternary),
#[prost(message, tag = "4")]
Lpm(Lpm),
#[prost(message, tag = "5")]
Range(Range),
#[prost(message, tag = "6")]
Optional(Optional),
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TableReadFlag {
#[prost(bool, tag = "1")]
pub from_hw: bool,
#[prost(bool, tag = "2")]
pub key_only: bool,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TableFlags {
#[prost(bool, tag = "1")]
pub from_hw: bool,
#[prost(bool, tag = "2")]
pub key_only: bool,
#[prost(bool, tag = "3")]
pub mod_del: bool,
#[prost(bool, tag = "4")]
pub reset_ttl: bool,
#[prost(bool, tag = "5")]
pub reset_stats: bool,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TableModIncFlag {
#[prost(enumeration = "table_mod_inc_flag::Type", tag = "1")]
pub r#type: i32,
}
pub mod table_mod_inc_flag {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Type {
ModIncAdd = 0,
ModIncDelete = 1,
}
impl Type {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::ModIncAdd => "MOD_INC_ADD",
Self::ModIncDelete => "MOD_INC_DELETE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"MOD_INC_ADD" => Some(Self::ModIncAdd),
"MOD_INC_DELETE" => Some(Self::ModIncDelete),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyFieldMask {
#[prost(uint32, tag = "1")]
pub field_id: u32,
#[prost(bytes = "vec", tag = "2")]
pub mask: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DynKeyMask {
#[prost(message, repeated, tag = "1")]
pub fields: ::prost::alloc::vec::Vec<KeyFieldMask>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DynHashing {
#[prost(uint32, tag = "1")]
pub alg: u32,
#[prost(uint64, tag = "2")]
pub seed: u64,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ByteCountAdj {
#[prost(int32, tag = "1")]
pub byte_count_adjust: i32,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct IdleTable {
#[prost(uint32, tag = "1")]
pub ttl_query_interval: u32,
#[prost(uint32, tag = "2")]
pub max_ttl: u32,
#[prost(uint32, tag = "3")]
pub min_ttl: u32,
#[prost(enumeration = "idle_table::IdleTableMode", tag = "4")]
pub idle_table_mode: i32,
#[prost(bool, tag = "5")]
pub enable: bool,
}
pub mod idle_table {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum IdleTableMode {
IdleTablePollMode = 0,
IdleTableNotifyMode = 1,
}
impl IdleTableMode {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::IdleTablePollMode => "IDLE_TABLE_POLL_MODE",
Self::IdleTableNotifyMode => "IDLE_TABLE_NOTIFY_MODE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"IDLE_TABLE_POLL_MODE" => Some(Self::IdleTablePollMode),
"IDLE_TABLE_NOTIFY_MODE" => Some(Self::IdleTableNotifyMode),
_ => None,
}
}
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct StatePullIntvl {
#[prost(uint32, tag = "1")]
pub intvl_val: u32,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PortStatusChg {
#[prost(bool, tag = "1")]
pub enable: bool,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Mode {
#[prost(uint64, tag = "3")]
pub args: u64,
#[prost(oneof = "mode::Scope", tags = "1, 2")]
pub scope: ::core::option::Option<mode::Scope>,
}
pub mod mode {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PredefinedMode {
All = 0,
Single = 1,
}
impl PredefinedMode {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::All => "ALL",
Self::Single => "SINGLE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ALL" => Some(Self::All),
"SINGLE" => Some(Self::Single),
_ => None,
}
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum Scope {
#[prost(enumeration = "PredefinedMode", tag = "1")]
Predef(i32),
#[prost(uint64, tag = "2")]
UserDefined(u64),
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PreGlobalRid {
#[prost(uint32, tag = "1")]
pub global_rid: u32,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PrePortProtection {
#[prost(bool, tag = "1")]
pub enable: bool,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PreFastFailover {
#[prost(bool, tag = "1")]
pub enable: bool,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PreMaxNodesBeforeYield {
#[prost(uint32, tag = "1")]
pub count: u32,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PreMaxNodeThreshold {
#[prost(uint32, tag = "1")]
pub node_count: u32,
#[prost(uint32, tag = "2")]
pub port_lag_count: u32,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PreDeviceConfig {
#[prost(message, optional, tag = "1")]
pub pre_global_rid: ::core::option::Option<PreGlobalRid>,
#[prost(message, optional, tag = "2")]
pub pre_port_protection: ::core::option::Option<PrePortProtection>,
#[prost(message, optional, tag = "3")]
pub pre_fast_failover: ::core::option::Option<PreFastFailover>,
#[prost(message, optional, tag = "4")]
pub pre_max_nodes_before_yield: ::core::option::Option<PreMaxNodesBeforeYield>,
#[prost(message, optional, tag = "5")]
pub pre_max_node_threshold: ::core::option::Option<PreMaxNodeThreshold>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct EntryScope {
#[prost(message, optional, tag = "1")]
pub gress_scope: ::core::option::Option<Mode>,
#[prost(message, optional, tag = "2")]
pub pipe_scope: ::core::option::Option<Mode>,
#[prost(message, optional, tag = "3")]
pub prsr_scope: ::core::option::Option<Mode>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ObjectId {
#[prost(uint32, tag = "3")]
pub id: u32,
#[prost(oneof = "object_id::Object", tags = "1, 2")]
pub object: ::core::option::Option<object_id::Object>,
}
pub mod object_id {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ActionName {
#[prost(string, tag = "1")]
pub action: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyFieldName {
#[prost(string, tag = "1")]
pub field: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataFieldName {
#[prost(string, tag = "1")]
pub action: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub field: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableObject {
#[prost(string, tag = "1")]
pub table_name: ::prost::alloc::string::String,
#[prost(oneof = "table_object::Names", tags = "2, 3, 4")]
pub names: ::core::option::Option<table_object::Names>,
}
pub mod table_object {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Names {
#[prost(message, tag = "2")]
ActionName(super::ActionName),
#[prost(message, tag = "3")]
KeyFieldName(super::KeyFieldName),
#[prost(message, tag = "4")]
DataFieldName(super::DataFieldName),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LearnObject {
#[prost(string, tag = "1")]
pub learn_name: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub data_field_name: ::core::option::Option<DataFieldName>,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Object {
#[prost(message, tag = "1")]
TableObject(TableObject),
#[prost(message, tag = "2")]
LearnObject(LearnObject),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamMessageRequest {
#[prost(uint32, tag = "1")]
pub client_id: u32,
#[prost(oneof = "stream_message_request::Update", tags = "2, 3")]
pub update: ::core::option::Option<stream_message_request::Update>,
}
pub mod stream_message_request {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Update {
#[prost(message, tag = "2")]
Subscribe(super::Subscribe),
#[prost(message, tag = "3")]
DigestAck(super::DigestListAck),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Subscribe {
#[deprecated]
#[prost(bool, tag = "1")]
pub is_master: bool,
#[prost(uint32, tag = "2")]
pub device_id: u32,
#[prost(message, optional, tag = "3")]
pub notifications: ::core::option::Option<subscribe::Notifications>,
#[prost(message, optional, tag = "4")]
pub status: ::core::option::Option<super::google::rpc::Status>,
}
pub mod subscribe {
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct Notifications {
#[prost(bool, tag = "1")]
pub enable_learn_notifications: bool,
#[prost(bool, tag = "2")]
pub enable_idletimeout_notifications: bool,
#[prost(bool, tag = "3")]
pub enable_port_status_change_notifications: bool,
#[prost(bool, tag = "4")]
pub enable_entry_active_notifications: bool,
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DigestListAck {
#[prost(uint32, tag = "1")]
pub digest_id: u32,
#[prost(uint32, tag = "2")]
pub list_id: u32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamMessageResponse {
#[prost(oneof = "stream_message_response::Update", tags = "1, 2, 3, 4, 5")]
pub update: ::core::option::Option<stream_message_response::Update>,
}
pub mod stream_message_response {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Update {
#[prost(message, tag = "1")]
Subscribe(super::Subscribe),
#[prost(message, tag = "2")]
Digest(super::DigestList),
#[prost(message, tag = "3")]
IdleTimeoutNotification(super::IdleTimeoutNotification),
#[prost(message, tag = "4")]
PortStatusChangeNotification(super::PortStatusChgNotification),
#[prost(message, tag = "5")]
SetForwardingPipelineConfigResponse(super::SetForwardingPipelineConfigResponse),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubscribeResponse {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<Error>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DigestList {
#[prost(uint32, tag = "1")]
pub digest_id: u32,
#[prost(uint32, tag = "2")]
pub list_id: u32,
#[prost(message, repeated, tag = "3")]
pub data: ::prost::alloc::vec::Vec<TableData>,
#[prost(message, optional, tag = "4")]
pub target: ::core::option::Option<TargetDevice>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IdleTimeoutNotification {
#[prost(message, optional, tag = "1")]
pub target: ::core::option::Option<TargetDevice>,
#[prost(message, optional, tag = "2")]
pub table_entry: ::core::option::Option<TableEntry>,
#[prost(enumeration = "idle_timeout_notification::NotificationType", tag = "3")]
pub r#type: i32,
}
pub mod idle_timeout_notification {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum NotificationType {
EntryActive = 0,
EntryIdle = 1,
}
impl NotificationType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::EntryActive => "ENTRY_ACTIVE",
Self::EntryIdle => "ENTRY_IDLE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ENTRY_ACTIVE" => Some(Self::EntryActive),
"ENTRY_IDLE" => Some(Self::EntryIdle),
_ => None,
}
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PortStatusChgNotification {
#[prost(message, optional, tag = "1")]
pub table_entry: ::core::option::Option<TableEntry>,
#[prost(bool, tag = "2")]
pub port_up: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetForwardingPipelineConfigRequest {
#[prost(uint32, tag = "1")]
pub device_id: u32,
#[prost(uint32, tag = "2")]
pub client_id: u32,
#[prost(
enumeration = "set_forwarding_pipeline_config_request::Action",
tag = "3"
)]
pub action: i32,
#[prost(
enumeration = "set_forwarding_pipeline_config_request::DevInitMode",
tag = "4"
)]
pub dev_init_mode: i32,
#[prost(string, tag = "5")]
pub base_path: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "6")]
pub config: ::prost::alloc::vec::Vec<ForwardingPipelineConfig>,
}
pub mod set_forwarding_pipeline_config_request {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Action {
Bind = 0,
Verify = 1,
VerifyAndWarmInitBegin = 2,
VerifyAndWarmInitBeginAndEnd = 3,
WarmInitEnd = 4,
ReconcileAndWarmInitEnd = 5,
}
impl Action {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Bind => "BIND",
Self::Verify => "VERIFY",
Self::VerifyAndWarmInitBegin => "VERIFY_AND_WARM_INIT_BEGIN",
Self::VerifyAndWarmInitBeginAndEnd => "VERIFY_AND_WARM_INIT_BEGIN_AND_END",
Self::WarmInitEnd => "WARM_INIT_END",
Self::ReconcileAndWarmInitEnd => "RECONCILE_AND_WARM_INIT_END",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"BIND" => Some(Self::Bind),
"VERIFY" => Some(Self::Verify),
"VERIFY_AND_WARM_INIT_BEGIN" => Some(Self::VerifyAndWarmInitBegin),
"VERIFY_AND_WARM_INIT_BEGIN_AND_END" => Some(Self::VerifyAndWarmInitBeginAndEnd),
"WARM_INIT_END" => Some(Self::WarmInitEnd),
"RECONCILE_AND_WARM_INIT_END" => Some(Self::ReconcileAndWarmInitEnd),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DevInitMode {
FastReconfig = 0,
Hitless = 1,
}
impl DevInitMode {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::FastReconfig => "FAST_RECONFIG",
Self::Hitless => "HITLESS",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"FAST_RECONFIG" => Some(Self::FastReconfig),
"HITLESS" => Some(Self::Hitless),
_ => None,
}
}
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct SetForwardingPipelineConfigResponse {
#[prost(enumeration = "SetForwardingPipelineConfigResponseType", tag = "1")]
pub set_forwarding_pipeline_config_response_type: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardingPipelineConfig {
#[prost(string, tag = "1")]
pub p4_name: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub bfruntime_info: ::prost::alloc::vec::Vec<u8>,
#[prost(message, repeated, tag = "3")]
pub profiles: ::prost::alloc::vec::Vec<forwarding_pipeline_config::Profile>,
}
pub mod forwarding_pipeline_config {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Profile {
#[prost(string, tag = "1")]
pub profile_name: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "2")]
pub context: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "3")]
pub binary: ::prost::alloc::vec::Vec<u8>,
#[prost(uint32, repeated, tag = "4")]
pub pipe_scope: ::prost::alloc::vec::Vec<u32>,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NonP4Config {
#[prost(bytes = "vec", tag = "1")]
pub bfruntime_info: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct GetForwardingPipelineConfigRequest {
#[prost(uint32, tag = "1")]
pub device_id: u32,
#[prost(uint32, tag = "2")]
pub client_id: u32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetForwardingPipelineConfigResponse {
#[prost(message, repeated, tag = "1")]
pub config: ::prost::alloc::vec::Vec<ForwardingPipelineConfig>,
#[prost(message, optional, tag = "2")]
pub non_p4_config: ::core::option::Option<NonP4Config>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Error {
#[prost(int32, tag = "1")]
pub canonical_code: i32,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub space: ::prost::alloc::string::String,
#[prost(int32, tag = "4")]
pub code: i32,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SetForwardingPipelineConfigResponseType {
WarmInitStarted = 0,
WarmInitFinished = 1,
}
impl SetForwardingPipelineConfigResponseType {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::WarmInitStarted => "WARM_INIT_STARTED",
Self::WarmInitFinished => "WARM_INIT_FINISHED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"WARM_INIT_STARTED" => Some(Self::WarmInitStarted),
"WARM_INIT_FINISHED" => Some(Self::WarmInitFinished),
_ => None,
}
}
}
pub mod bf_runtime_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value
)]
use tonic::codegen::http::Uri;
use tonic::codegen::*;
#[derive(Debug, Clone)]
pub struct BfRuntimeClient<T> {
inner: tonic::client::Grpc<T>,
}
impl BfRuntimeClient<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> BfRuntimeClient<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,
) -> BfRuntimeClient<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,
{
BfRuntimeClient::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 write(
&mut self,
request: impl tonic::IntoRequest<super::WriteRequest>,
) -> std::result::Result<tonic::Response<super::WriteResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/bfrt_proto.BfRuntime/Write");
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("bfrt_proto.BfRuntime", "Write"));
self.inner.unary(req, path, codec).await
}
pub async fn read(
&mut self,
request: impl tonic::IntoRequest<super::ReadRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ReadResponse>>,
tonic::Status,
> {
self.inner.ready().await.map_err(|e| {
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/bfrt_proto.BfRuntime/Read");
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("bfrt_proto.BfRuntime", "Read"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn set_forwarding_pipeline_config(
&mut self,
request: impl tonic::IntoRequest<super::SetForwardingPipelineConfigRequest>,
) -> std::result::Result<
tonic::Response<super::SetForwardingPipelineConfigResponse>,
tonic::Status,
> {
self.inner.ready().await.map_err(|e| {
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/bfrt_proto.BfRuntime/SetForwardingPipelineConfig",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new(
"bfrt_proto.BfRuntime",
"SetForwardingPipelineConfig",
));
self.inner.unary(req, path, codec).await
}
pub async fn get_forwarding_pipeline_config(
&mut self,
request: impl tonic::IntoRequest<super::GetForwardingPipelineConfigRequest>,
) -> std::result::Result<
tonic::Response<super::GetForwardingPipelineConfigResponse>,
tonic::Status,
> {
self.inner.ready().await.map_err(|e| {
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/bfrt_proto.BfRuntime/GetForwardingPipelineConfig",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new(
"bfrt_proto.BfRuntime",
"GetForwardingPipelineConfig",
));
self.inner.unary(req, path, codec).await
}
pub async fn stream_channel(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::StreamMessageRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::StreamMessageResponse>>,
tonic::Status,
> {
self.inner.ready().await.map_err(|e| {
tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/bfrt_proto.BfRuntime/StreamChannel");
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(GrpcMethod::new("bfrt_proto.BfRuntime", "StreamChannel"));
self.inner.streaming(req, path, codec).await
}
}
}
pub mod bf_runtime_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value
)]
use tonic::codegen::*;
#[async_trait]
pub trait BfRuntime: std::marker::Send + std::marker::Sync + 'static {
async fn write(
&self,
request: tonic::Request<super::WriteRequest>,
) -> std::result::Result<tonic::Response<super::WriteResponse>, tonic::Status>;
type ReadStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::ReadResponse, tonic::Status>,
> + std::marker::Send
+ 'static;
async fn read(
&self,
request: tonic::Request<super::ReadRequest>,
) -> std::result::Result<tonic::Response<Self::ReadStream>, tonic::Status>;
async fn set_forwarding_pipeline_config(
&self,
request: tonic::Request<super::SetForwardingPipelineConfigRequest>,
) -> std::result::Result<
tonic::Response<super::SetForwardingPipelineConfigResponse>,
tonic::Status,
>;
async fn get_forwarding_pipeline_config(
&self,
request: tonic::Request<super::GetForwardingPipelineConfigRequest>,
) -> std::result::Result<
tonic::Response<super::GetForwardingPipelineConfigResponse>,
tonic::Status,
>;
type StreamChannelStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::StreamMessageResponse, tonic::Status>,
> + std::marker::Send
+ 'static;
async fn stream_channel(
&self,
request: tonic::Request<tonic::Streaming<super::StreamMessageRequest>>,
) -> std::result::Result<tonic::Response<Self::StreamChannelStream>, tonic::Status>;
}
#[derive(Debug)]
pub struct BfRuntimeServer<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> BfRuntimeServer<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 BfRuntimeServer<T>
where
T: BfRuntime,
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() {
"/bfrt_proto.BfRuntime/Write" => {
#[allow(non_camel_case_types)]
struct WriteSvc<T: BfRuntime>(pub Arc<T>);
impl<T: BfRuntime> tonic::server::UnaryService<super::WriteRequest> for WriteSvc<T> {
type Response = super::WriteResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::WriteRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move { <T as BfRuntime>::write(&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 = WriteSvc(inner);
let codec = tonic_prost::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)
}
"/bfrt_proto.BfRuntime/Read" => {
#[allow(non_camel_case_types)]
struct ReadSvc<T: BfRuntime>(pub Arc<T>);
impl<T: BfRuntime> tonic::server::ServerStreamingService<super::ReadRequest> for ReadSvc<T> {
type Response = super::ReadResponse;
type ResponseStream = T::ReadStream;
type Future =
BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::ReadRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move { <T as BfRuntime>::read(&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 = ReadSvc(inner);
let codec = tonic_prost::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.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/bfrt_proto.BfRuntime/SetForwardingPipelineConfig" => {
#[allow(non_camel_case_types)]
struct SetForwardingPipelineConfigSvc<T: BfRuntime>(pub Arc<T>);
impl<T: BfRuntime>
tonic::server::UnaryService<super::SetForwardingPipelineConfigRequest>
for SetForwardingPipelineConfigSvc<T>
{
type Response = super::SetForwardingPipelineConfigResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::SetForwardingPipelineConfigRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as BfRuntime>::set_forwarding_pipeline_config(&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 = SetForwardingPipelineConfigSvc(inner);
let codec = tonic_prost::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)
}
"/bfrt_proto.BfRuntime/GetForwardingPipelineConfig" => {
#[allow(non_camel_case_types)]
struct GetForwardingPipelineConfigSvc<T: BfRuntime>(pub Arc<T>);
impl<T: BfRuntime>
tonic::server::UnaryService<super::GetForwardingPipelineConfigRequest>
for GetForwardingPipelineConfigSvc<T>
{
type Response = super::GetForwardingPipelineConfigResponse;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<super::GetForwardingPipelineConfigRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as BfRuntime>::get_forwarding_pipeline_config(&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 = GetForwardingPipelineConfigSvc(inner);
let codec = tonic_prost::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)
}
"/bfrt_proto.BfRuntime/StreamChannel" => {
#[allow(non_camel_case_types)]
struct StreamChannelSvc<T: BfRuntime>(pub Arc<T>);
impl<T: BfRuntime> tonic::server::StreamingService<super::StreamMessageRequest>
for StreamChannelSvc<T>
{
type Response = super::StreamMessageResponse;
type ResponseStream = T::StreamChannelStream;
type Future =
BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(
&mut self,
request: tonic::Request<tonic::Streaming<super::StreamMessageRequest>>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as BfRuntime>::stream_channel(&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 = StreamChannelSvc(inner);
let codec = tonic_prost::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 BfRuntimeServer<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 = "bfrt_proto.BfRuntime";
impl<T> tonic::server::NamedService for BfRuntimeServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}