Skip to content

Commit 8230301

Browse files
gefjoncloutiertyler
authored andcommitted
Rename host argument in SDK's connect to spacetimedb_uri (#119)
This commit renames the first argument to connect from host to spacetimedb_uri. It's not just a host(name), it's the URI of the SpacetimeDB instance.
1 parent a2c712a commit 8230301

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

crates/cli/src/subcommands/generate/rust.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ fn print_handle_event_defn(out: &mut Indenter, items: &[GenItem]) {
10011001
}
10021002

10031003
const CONNECT_DOCSTRING: &[&str] = &[
1004-
"/// Connect to a database named `db_name` accessible over the internet at the URI `host`.",
1004+
"/// Connect to a database named `db_name` accessible over the internet at the URI `spacetimedb_uri`.",
10051005
"///",
10061006
"/// If `credentials` are supplied, they will be passed to the new connection to",
10071007
"/// identify and authenticate the user. Otherwise, a set of `Credentials` will be",
@@ -1017,17 +1017,17 @@ fn print_connect_docstring(out: &mut Indenter) {
10171017
fn print_connect_defn(out: &mut Indenter) {
10181018
print_connect_docstring(out);
10191019
out.delimited_block(
1020-
"pub fn connect<Host>(host: Host, db_name: &str, credentials: Option<Credentials>) -> Result<()>
1020+
"pub fn connect<IntoUri>(spacetimedb_uri: IntoUri, db_name: &str, credentials: Option<Credentials>) -> Result<()>
10211021
where
1022-
\tHost: TryInto<spacetimedb_sdk::http::Uri>,
1023-
\t<Host as TryInto<spacetimedb_sdk::http::Uri>>::Error: std::error::Error + Send + Sync + 'static,
1022+
\tIntoUri: TryInto<spacetimedb_sdk::http::Uri>,
1023+
\t<IntoUri as TryInto<spacetimedb_sdk::http::Uri>>::Error: std::error::Error + Send + Sync + 'static,
10241024
{",
10251025
|out| out.delimited_block(
10261026
"with_connection_mut(|connection| {",
10271027
|out| {
10281028
writeln!(
10291029
out,
1030-
"connection.connect(host, db_name, credentials, handle_table_update, handle_resubscribe, invoke_row_callbacks, handle_event)?;"
1030+
"connection.connect(spacetimedb_uri, db_name, credentials, handle_table_update, handle_resubscribe, invoke_row_callbacks, handle_event)?;"
10311031
).unwrap();
10321032
writeln!(out, "Ok(())").unwrap();
10331033
},

crates/sdk/src/background_connection.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl BackgroundDbConnection {
275275
))
276276
}
277277

278-
/// Connect to a database named `db_name` accessible over the internet at the URI `host`.
278+
/// Connect to a database named `db_name` accessible over the internet at the URI `spacetimedb_uri`.
279279
///
280280
/// If `credentials` are supplied, they will be passed to the new connection to
281281
/// identify and authenticate the user. Otherwise, a set of `Credentials` will be
@@ -293,9 +293,9 @@ impl BackgroundDbConnection {
293293
// calls are autogenerated by the CLI,
294294
// with a wrapper that takes only 3 arguments.
295295
#[allow(clippy::too_many_arguments)]
296-
pub fn connect<Host>(
296+
pub fn connect<IntoUri>(
297297
&mut self,
298-
host: Host,
298+
spacetimedb_uri: IntoUri,
299299
db_name: &str,
300300
credentials: Option<Credentials>,
301301
handle_table_update: crate::client_cache::HandleTableUpdateFn,
@@ -304,14 +304,14 @@ impl BackgroundDbConnection {
304304
handle_event: crate::callbacks::HandleEventFn,
305305
) -> Result<()>
306306
where
307-
Host: TryInto<http::Uri>,
308-
<Host as TryInto<http::Uri>>::Error: std::error::Error + Send + Sync + 'static,
307+
IntoUri: TryInto<http::Uri>,
308+
<IntoUri as TryInto<http::Uri>>::Error: std::error::Error + Send + Sync + 'static,
309309
{
310310
// `block_in_place` is required here, as tokio won't allow us to call
311311
// `block_on` if it would block the current thread of an outer runtime
312312
let connection = tokio::task::block_in_place(|| {
313313
self.handle
314-
.block_on(DbConnection::connect(host, db_name, credentials.as_ref()))
314+
.block_on(DbConnection::connect(spacetimedb_uri, db_name, credentials.as_ref()))
315315
})?;
316316
let client_cache = Arc::new(Mutex::new(Arc::new(ClientCache::new(
317317
handle_table_update,

0 commit comments

Comments
 (0)