diff --git a/thrift/compiler/generate/templates/rust/lib/method_metadata.mustache b/thrift/compiler/generate/templates/rust/lib/method_metadata.mustache new file mode 100644 index 00000000000..c0cd3b285da --- /dev/null +++ b/thrift/compiler/generate/templates/rust/lib/method_metadata.mustache @@ -0,0 +1,70 @@ +{{! + + Copyright (c) Meta Platforms, Inc. and affiliates. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +}} + // From {{service:program_name}}.{{service:name}}: +{{^service:interaction?}} +{{#service:rustFunctions}} + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + {{#function:stream?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + {{/function:stream?}} + {{^function:stream?}}{{#function:sink?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + {{/function:sink?}}{{/function:stream?}} + {{^function:stream?}}{{^function:sink?}} + {{#function:return_type}}{{#type:void?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + {{/type:void?}}{{^type:void?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + {{/type:void?}}{{/function:return_type}} + {{/function:sink?}}{{/function:stream?}} + name: "{{function:name}}", + starts_interaction: {{#function:starts_interaction?}}true{{/function:starts_interaction?}}{{^function:starts_interaction?}}false{{/function:starts_interaction?}}, + interaction_name: {{#function:starts_interaction?}}Some("{{service:name}}"){{/function:starts_interaction?}}{{^function:starts_interaction?}}None{{/function:starts_interaction?}}, + }, +{{/service:rustFunctions}} +{{#service:interactions}}{{#service:rustFunctions}} + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + {{#function:stream?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + {{/function:stream?}} + {{^function:stream?}}{{#function:sink?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + {{/function:sink?}}{{/function:stream?}} + {{^function:stream?}}{{^function:sink?}} + {{#function:return_type}}{{#type:void?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + {{/type:void?}}{{^type:void?}} + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + {{/type:void?}}{{/function:return_type}} + {{/function:sink?}}{{/function:stream?}} + name: "{{service:name}}.{{function:name}}", + starts_interaction: false, + interaction_name: Some("{{service:name}}"), + }, +{{/service:rustFunctions}}{{/service:interactions}} +{{/service:interaction?}} +{{#service:interaction?}} + // Interaction's method names are never queried directly. + // They are always queried from the "main" processor. +{{/service:interaction?}} +{{#service:extends}} + +{{>lib/method_metadata}} +{{/service:extends}} diff --git a/thrift/compiler/generate/templates/rust/lib/method_names.mustache b/thrift/compiler/generate/templates/rust/lib/method_names.mustache deleted file mode 100644 index 3e2912f8a87..00000000000 --- a/thrift/compiler/generate/templates/rust/lib/method_names.mustache +++ /dev/null @@ -1,34 +0,0 @@ -{{! - - Copyright (c) Meta Platforms, Inc. and affiliates. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -}} - // From {{service:program_name}}.{{service:name}}: -{{^service:interaction?}} -{{#service:rustFunctions}}{{^function:starts_interaction?}} - "{{function:name}}", -{{/function:starts_interaction?}}{{/service:rustFunctions}} -{{#service:interactions}}{{#service:rustFunctions}} - "{{service:name}}.{{function:name}}", -{{/service:rustFunctions}}{{/service:interactions}} -{{/service:interaction?}} -{{#service:interaction?}} - // Interaction's method names are never queried directly. - // They are always queried from the "main" processor. -{{/service:interaction?}} -{{#service:extends}} - -{{>lib/method_names}} -{{/service:extends}} diff --git a/thrift/compiler/generate/templates/rust/lib/server.mustache b/thrift/compiler/generate/templates/rust/lib/server.mustache index aad9361f8a0..97b954b2193 100644 --- a/thrift/compiler/generate/templates/rust/lib/server.mustache +++ b/thrift/compiler/generate/templates/rust/lib/server.mustache @@ -427,9 +427,9 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ -{{>lib/method_names}} +{{>lib/method_metadata}} ] } diff --git a/thrift/compiler/test/fixtures/adapter/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/adapter/out/rust/gen-rust/server.rs index af6f3ffc483..89d4d42a08c 100644 --- a/thrift/compiler/test/fixtures/adapter/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/adapter/out/rust/gen-rust/server.rs @@ -359,10 +359,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.Service: - "func", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "func", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -825,11 +831,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.AdapterService: - "count", - "adaptedTypes", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "count", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "adaptedTypes", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/basic-annotations/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/basic-annotations/out/rust/gen-rust/server.rs index dc5ab01150f..a13b99346bd 100644 --- a/thrift/compiler/test/fixtures/basic-annotations/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/basic-annotations/out/rust/gen-rust/server.rs @@ -1158,16 +1158,58 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyService: - "ping", - "getRandomData", - "hasDataById", - "getDataById", - "putDataById", - "lobDataById", - "doNothing", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "ping", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getRandomData", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "hasDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "putDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "lobDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "doNothing", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -1619,11 +1661,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyServicePrioParent: - "ping", - "pong", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "ping", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "pong", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -1970,14 +2024,32 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyServicePrioChild: - "pang", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "pang", + starts_interaction: false, + interaction_name: None, + }, // From module.MyServicePrioParent: - "ping", - "pong", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "ping", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "pong", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -2265,7 +2337,7 @@ pub mod bad_service { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.BadInteraction: // Interaction's method names are never queried directly. @@ -2606,11 +2678,30 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.BadService: - "bar", - "BadInteraction.foo", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createBadInteraction", + starts_interaction: true, + interaction_name: Some("BadService"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "bar", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "BadInteraction.foo", + starts_interaction: false, + interaction_name: Some("BadInteraction"), + }, ] } @@ -3174,12 +3265,30 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.FooBarBazService: - "foo", - "bar", - "baz", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "foo", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "bar", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "baz", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/basic/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/basic/out/rust/gen-rust/server.rs index 2254c630a33..b3e8e4d8790 100644 --- a/thrift/compiler/test/fixtures/basic/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/basic/out/rust/gen-rust/server.rs @@ -338,10 +338,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.FooService: - "simple_rpc", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "simple_rpc", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -692,10 +698,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.FB303Service: - "simple_rpc", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "simple_rpc", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -2131,19 +2143,79 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyService: - "ping", - "getRandomData", - "sink", - "putDataById", - "hasDataById", - "getDataById", - "deleteDataById", - "lobDataById", - "invalid_return_for_hack", - "rpc_skipped_codegen", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "ping", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getRandomData", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "sink", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "putDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "hasDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "deleteDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "lobDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "invalid_return_for_hack", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "rpc_skipped_codegen", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -2617,11 +2689,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.DbMixedStackArguments: - "getDataByKey0", - "getDataByKey1", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getDataByKey0", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getDataByKey1", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/doctext/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/doctext/out/rust/gen-rust/server.rs index 41b36e418d8..cfcad98513c 100644 --- a/thrift/compiler/test/fixtures/doctext/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/doctext/out/rust/gen-rust/server.rs @@ -619,12 +619,30 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.C: - "f", - "numbers", - "thing", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "f", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "numbers", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "thing", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/exceptions/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/exceptions/out/rust/gen-rust/server.rs index 4723c30fc11..68a680237c1 100644 --- a/thrift/compiler/test/fixtures/exceptions/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/exceptions/out/rust/gen-rust/server.rs @@ -656,13 +656,37 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.Raiser: - "doBland", - "doRaise", - "get200", - "get500", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "doBland", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "doRaise", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "get200", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "get500", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/inheritance/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/inheritance/out/rust/gen-rust/server.rs index 58300cc8f63..46148839a12 100644 --- a/thrift/compiler/test/fixtures/inheritance/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/inheritance/out/rust/gen-rust/server.rs @@ -332,10 +332,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyRoot: - "do_root", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "do_root", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -682,13 +688,25 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyNode: - "do_mid", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "do_mid", + starts_interaction: false, + interaction_name: None, + }, // From module.MyRoot: - "do_root", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "do_root", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -1039,16 +1057,34 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyLeaf: - "do_leaf", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "do_leaf", + starts_interaction: false, + interaction_name: None, + }, // From module.MyNode: - "do_mid", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "do_mid", + starts_interaction: false, + interaction_name: None, + }, // From module.MyRoot: - "do_root", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "do_root", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/interactions/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/interactions/out/rust/gen-rust/server.rs index 8edaca1fbe5..caf67c5d4a6 100644 --- a/thrift/compiler/test/fixtures/interactions/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/interactions/out/rust/gen-rust/server.rs @@ -869,7 +869,7 @@ pub mod my_service { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteraction: // Interaction's method names are never queried directly. @@ -1287,7 +1287,7 @@ pub mod my_service { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteractionFast: // Interaction's method names are never queried directly. @@ -1540,7 +1540,7 @@ pub mod my_service { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.SerialInteraction: // Interaction's method names are never queried directly. @@ -2338,22 +2338,121 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyService: - "foo", - "interact", - "interactFast", - "serialize", - "MyInteraction.frobnicate", - "MyInteraction.ping", - "MyInteraction.truthify", - "MyInteraction.encode", - "MyInteractionFast.frobnicate", - "MyInteractionFast.ping", - "MyInteractionFast.truthify", - "MyInteractionFast.encode", - "SerialInteraction.frobnicate", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createMyInteraction", + starts_interaction: true, + interaction_name: Some("MyService"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createMyInteractionFast", + starts_interaction: true, + interaction_name: Some("MyService"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createSerialInteraction", + starts_interaction: true, + interaction_name: Some("MyService"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "foo", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "interact", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "interactFast", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "serialize", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "MyInteraction.frobnicate", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteraction.ping", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "MyInteraction.truthify", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + name: "MyInteraction.encode", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "MyInteractionFast.frobnicate", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteractionFast.ping", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "MyInteractionFast.truthify", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + name: "MyInteractionFast.encode", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "SerialInteraction.frobnicate", + starts_interaction: false, + interaction_name: Some("SerialInteraction"), + }, ] } @@ -2802,7 +2901,7 @@ pub mod factories { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteraction: // Interaction's method names are never queried directly. @@ -3220,7 +3319,7 @@ pub mod factories { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteractionFast: // Interaction's method names are never queried directly. @@ -3473,7 +3572,7 @@ pub mod factories { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.SerialInteraction: // Interaction's method names are never queried directly. @@ -4190,22 +4289,100 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.Factories: - "foo", - "interact", - "interactFast", - "serialize", - "MyInteraction.frobnicate", - "MyInteraction.ping", - "MyInteraction.truthify", - "MyInteraction.encode", - "MyInteractionFast.frobnicate", - "MyInteractionFast.ping", - "MyInteractionFast.truthify", - "MyInteractionFast.encode", - "SerialInteraction.frobnicate", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "foo", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "interact", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "interactFast", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "serialize", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "MyInteraction.frobnicate", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteraction.ping", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "MyInteraction.truthify", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + name: "MyInteraction.encode", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "MyInteractionFast.frobnicate", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteractionFast.ping", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "MyInteractionFast.truthify", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + name: "MyInteractionFast.encode", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "SerialInteraction.frobnicate", + starts_interaction: false, + interaction_name: Some("SerialInteraction"), + }, ] } @@ -4654,7 +4831,7 @@ pub mod perform { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteraction: // Interaction's method names are never queried directly. @@ -5072,7 +5249,7 @@ pub mod perform { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteractionFast: // Interaction's method names are never queried directly. @@ -5325,7 +5502,7 @@ pub mod perform { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.SerialInteraction: // Interaction's method names are never queried directly. @@ -5720,19 +5897,100 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.Perform: - "foo", - "MyInteraction.frobnicate", - "MyInteraction.ping", - "MyInteraction.truthify", - "MyInteraction.encode", - "MyInteractionFast.frobnicate", - "MyInteractionFast.ping", - "MyInteractionFast.truthify", - "MyInteractionFast.encode", - "SerialInteraction.frobnicate", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createMyInteraction", + starts_interaction: true, + interaction_name: Some("Perform"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createMyInteractionFast", + starts_interaction: true, + interaction_name: Some("Perform"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createSerialInteraction", + starts_interaction: true, + interaction_name: Some("Perform"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "foo", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "MyInteraction.frobnicate", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteraction.ping", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "MyInteraction.truthify", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + name: "MyInteraction.encode", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "MyInteractionFast.frobnicate", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteractionFast.ping", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "MyInteractionFast.truthify", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + name: "MyInteractionFast.encode", + starts_interaction: false, + interaction_name: Some("MyInteractionFast"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "SerialInteraction.frobnicate", + starts_interaction: false, + interaction_name: Some("SerialInteraction"), + }, ] } @@ -6181,7 +6439,7 @@ pub mod interact_with_shared { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteraction: // Interaction's method names are never queried directly. @@ -6564,7 +6822,7 @@ pub mod interact_with_shared { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From shared.SharedInteraction: // Interaction's method names are never queried directly. @@ -6932,17 +7190,79 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.InteractWithShared: - "do_some_similar_things", - "MyInteraction.frobnicate", - "MyInteraction.ping", - "MyInteraction.truthify", - "MyInteraction.encode", - "SharedInteraction.init", - "SharedInteraction.do_something", - "SharedInteraction.tear_down", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "do_some_similar_things", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createMyInteraction", + starts_interaction: true, + interaction_name: Some("InteractWithShared"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createshared.SharedInteraction", + starts_interaction: true, + interaction_name: Some("InteractWithShared"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "MyInteraction.frobnicate", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteraction.ping", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "MyInteraction.truthify", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINK, + name: "MyInteraction.encode", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "SharedInteraction.init", + starts_interaction: false, + interaction_name: Some("SharedInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "SharedInteraction.do_something", + starts_interaction: false, + interaction_name: Some("SharedInteraction"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "SharedInteraction.tear_down", + starts_interaction: false, + interaction_name: Some("SharedInteraction"), + }, ] } diff --git a/thrift/compiler/test/fixtures/namespace_from_package/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/namespace_from_package/out/rust/gen-rust/server.rs index 80ee5e30d6e..4aa6b72f777 100644 --- a/thrift/compiler/test/fixtures/namespace_from_package/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/namespace_from_package/out/rust/gen-rust/server.rs @@ -331,10 +331,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.TestService: - "init", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "init", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/rust/gen-rust/server.rs index fef8c444f80..51eefe134c7 100644 --- a/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/namespace_from_package_without_module_name/out/rust/gen-rust/server.rs @@ -331,10 +331,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.TestService: - "init", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "init", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/params/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/params/out/rust/gen-rust/server.rs index 5108b08f9a0..c41e6dfe65b 100644 --- a/thrift/compiler/test/fixtures/params/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/params/out/rust/gen-rust/server.rs @@ -823,14 +823,44 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.NestedContainers: - "mapList", - "mapSet", - "listMap", - "listSet", - "turtles", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "mapList", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "mapSet", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "listMap", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "listSet", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "turtles", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/rust-annotations/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/rust-annotations/out/rust/gen-rust/server.rs index 28203fc9ede..e79407d8f60 100644 --- a/thrift/compiler/test/fixtures/rust-annotations/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/rust-annotations/out/rust/gen-rust/server.rs @@ -351,10 +351,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.S1: - "r", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "r", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -694,10 +700,16 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.S2: - "r", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "r", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -1149,11 +1161,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.AllMethods: - "foo", - "bar", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "foo", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "bar", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -1605,11 +1629,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.OneMethod: - "foo", - "bar", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "foo", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "bar", + starts_interaction: false, + interaction_name: None, + }, ] } @@ -2061,11 +2097,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.OneMethodOptOut: - "foo", - "bar", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "foo", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "bar", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/rust-raw-identifiers/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/rust-raw-identifiers/out/rust/gen-rust/server.rs index 7cc9a85716c..ce9dbdfc84b 100644 --- a/thrift/compiler/test/fixtures/rust-raw-identifiers/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/rust-raw-identifiers/out/rust/gen-rust/server.rs @@ -454,11 +454,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From mod.Foo: - "return", - "super", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "return", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "super", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/rust-request-context/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/rust-request-context/out/rust/gen-rust/server.rs index 887c060df4e..dee59ef10fd 100644 --- a/thrift/compiler/test/fixtures/rust-request-context/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/rust-request-context/out/rust/gen-rust/server.rs @@ -340,7 +340,7 @@ pub mod my_service { self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyInteraction: // Interaction's method names are never queried directly. @@ -1983,20 +1983,93 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyService: - "ping", - "getRandomData", - "hasDataById", - "getDataById", - "putDataById", - "lobDataById", - "streamById", - "streamByIdWithException", - "streamByIdWithResponse", - "startPingInteraction", - "MyInteraction.ping", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "ping", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getRandomData", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "hasDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "putDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "lobDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "streamById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "streamByIdWithException", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "streamByIdWithResponse", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "createMyInteraction", + starts_interaction: true, + interaction_name: Some("MyService"), + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "startPingInteraction", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "MyInteraction.ping", + starts_interaction: false, + interaction_name: Some("MyInteraction"), + }, ] } diff --git a/thrift/compiler/test/fixtures/rust-skip-none-serialization/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/rust-skip-none-serialization/out/rust/gen-rust/server.rs index 8e36607d69d..6b7c43dd219 100644 --- a/thrift/compiler/test/fixtures/rust-skip-none-serialization/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/rust-skip-none-serialization/out/rust/gen-rust/server.rs @@ -946,15 +946,51 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.MyService: - "ping", - "getRandomData", - "hasDataById", - "getDataById", - "putDataById", - "lobDataById", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "ping", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getRandomData", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "hasDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "getDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "putDataById", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, + name: "lobDataById", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/stream/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/stream/out/rust/gen-rust/server.rs index 418123c224e..191629beb2d 100644 --- a/thrift/compiler/test/fixtures/stream/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/stream/out/rust/gen-rust/server.rs @@ -1738,18 +1738,72 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.PubSubStreamingService: - "returnstream", - "streamthrows", - "servicethrows", - "servicethrows2", - "boththrows", - "responseandstreamstreamthrows", - "responseandstreamservicethrows", - "responseandstreamboththrows", - "returnstreamFast", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "returnstream", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "streamthrows", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "servicethrows", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "servicethrows2", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "boththrows", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "responseandstreamstreamthrows", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "responseandstreamservicethrows", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "responseandstreamboththrows", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, + name: "returnstreamFast", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/compiler/test/fixtures/types/out/rust/gen-rust/server.rs b/thrift/compiler/test/fixtures/types/out/rust/gen-rust/server.rs index 45467ac9efc..2ca1ced549a 100644 --- a/thrift/compiler/test/fixtures/types/out/rust/gen-rust/server.rs +++ b/thrift/compiler/test/fixtures/types/out/rust/gen-rust/server.rs @@ -454,11 +454,23 @@ where self.handle_create_interaction(idx) } - fn get_method_names(&self) -> &'static [&'static ::std::primitive::str] { + fn get_method_metadata(&self) -> &'static [::fbthrift::processor::MethodMetadata] { &[ // From module.SomeService: - "bounce_map", - "binary_keyed_map", + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "bounce_map", + starts_interaction: false, + interaction_name: None, + }, + ::fbthrift::processor::MethodMetadata{ + interaction_type: ::fbthrift::processor::InteractionType::None, + rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, + name: "binary_keyed_map", + starts_interaction: false, + interaction_name: None, + }, ] } diff --git a/thrift/lib/rust/src/processor.rs b/thrift/lib/rust/src/processor.rs index faf04c82054..5c2eff74738 100644 --- a/thrift/lib/rust/src/processor.rs +++ b/thrift/lib/rust/src/processor.rs @@ -79,6 +79,37 @@ where } } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[repr(u8)] +pub enum InteractionType { + Unknown = 0, + None, + InteractionV1, +} + +// Source of truth: https://www.internalfb.com/code/fbsource/[747e817d8fc6ee1505b03e47629e34f40749b0ac]/fbcode/thrift/lib/thrift/RpcMetadata.thrift?lines=67-76 +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[allow(non_camel_case_types)] +#[repr(u8)] +pub enum RpcKind { + SINGLE_REQUEST_SINGLE_RESPONSE = 0, + SINGLE_REQUEST_NO_RESPONSE = 1, + // Unused: + // STREAMING_REQUEST_SINGLE_RESPONSE = 2, + // STREAMING_REQUEST_NO_RESPONSE = 3, + SINGLE_REQUEST_STREAMING_RESPONSE = 4, + // STREAMING_REQUEST_STREAMING_RESPONSE = 5, + SINK = 6, +} + +pub struct MethodMetadata { + pub interaction_type: InteractionType, + pub rpc_kind: RpcKind, + pub name: &'static str, + pub starts_interaction: bool, + pub interaction_name: Option<&'static str>, +} + #[async_trait] pub trait ThriftService: Send + Sync + 'static where @@ -112,12 +143,12 @@ where bail!("Thrift server does not support interactions"); } - /// Returns function names this thrift service is able to handle, similar - /// to the keys of C++'s createMethodMetadata(). + /// Returns function metadata for this thrift service, similar + /// to C++'s createMethodMetadata(). /// /// Return value includes inherited functions from parent thrift services, /// and interactions' functions. - fn get_method_names(&self) -> &'static [&'static str]; + fn get_method_metadata(&self) -> &'static [MethodMetadata]; /// Applies to interactions only /// @@ -167,8 +198,8 @@ where (**self).create_interaction(name) } - fn get_method_names(&self) -> &'static [&'static str] { - (**self).get_method_names() + fn get_method_metadata(&self) -> &'static [MethodMetadata] { + (**self).get_method_metadata() } async fn on_termination(&self) { @@ -214,8 +245,8 @@ where (**self).create_interaction(name) } - fn get_method_names(&self) -> &'static [&'static str] { - (**self).get_method_names() + fn get_method_metadata(&self) -> &'static [MethodMetadata] { + (**self).get_method_metadata() } async fn on_termination(&self) { @@ -414,7 +445,7 @@ where bail!("Unimplemented interaction {}", name); } - fn get_method_names(&self) -> &'static [&'static str] { + fn get_method_metadata(&self) -> &'static [MethodMetadata] { &[] }