extension/dap: Add resolve_tcp_template function (#31010)
Extensions cannot look up available port themselves, hence the new API. With this I'm able to port our Ruby implementation into an extension. Release Notes: - N/A
This commit is contained in:
parent
e4262f97af
commit
e5670ba081
6 changed files with 48 additions and 24 deletions
|
@ -6,6 +6,8 @@ pub mod proto_conversions;
|
|||
mod registry;
|
||||
pub mod transport;
|
||||
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
pub use dap_types::*;
|
||||
pub use registry::{DapLocator, DapRegistry};
|
||||
pub use task::DebugRequest;
|
||||
|
@ -16,3 +18,19 @@ pub type StackFrameId = u64;
|
|||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub use adapters::FakeAdapter;
|
||||
use task::TcpArgumentsTemplate;
|
||||
|
||||
pub async fn configure_tcp_connection(
|
||||
tcp_connection: TcpArgumentsTemplate,
|
||||
) -> anyhow::Result<(Ipv4Addr, u16, Option<u64>)> {
|
||||
let host = tcp_connection.host();
|
||||
let timeout = tcp_connection.timeout;
|
||||
|
||||
let port = if let Some(port) = tcp_connection.port {
|
||||
port
|
||||
} else {
|
||||
transport::TcpTransport::port(&tcp_connection).await?
|
||||
};
|
||||
|
||||
Ok((host, port, timeout))
|
||||
}
|
||||
|
|
|
@ -54,10 +54,6 @@ impl DapRegistry {
|
|||
pub fn add_adapter(&self, adapter: Arc<dyn DebugAdapter>) {
|
||||
let name = adapter.name();
|
||||
let _previous_value = self.0.write().adapters.insert(name, adapter);
|
||||
debug_assert!(
|
||||
_previous_value.is_none(),
|
||||
"Attempted to insert a new debug adapter when one is already registered"
|
||||
);
|
||||
}
|
||||
|
||||
pub fn adapter_language(&self, adapter_name: &str) -> Option<LanguageName> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue