···271271#[cfg_attr(not(target_arch = "wasm32"), trait_variant::make(Send))]
272272pub trait XrpcClient: HttpClient {
273273 /// Get the base URI for the client.
274274- fn base_uri(&self) -> impl Future<Output = Url>;
274274+ fn base_uri(&self) -> impl Future<Output = CowStr<'static>>;
275275276276 /// Set the base URI for the client.
277277 fn set_base_uri(&self, url: Url) -> impl Future<Output = ()> {
+8-4
crates/jacquard-common/src/xrpc/subscription.rs
···1313use std::marker::PhantomData;
1414use url::Url;
15151616+use crate::cowstr::ToCowStr;
1617use crate::error::DecodeError;
1718use crate::stream::StreamError;
1819use crate::websocket::{WebSocketClient, WebSocketConnection, WsSink, WsStream};
···792793#[cfg_attr(not(target_arch = "wasm32"), trait_variant::make(Send))]
793794pub trait SubscriptionClient: WebSocketClient {
794795 /// Get the base URI for the client.
795795- fn base_uri(&self) -> impl Future<Output = Url>;
796796+ fn base_uri(&self) -> impl Future<Output = CowStr<'static>>;
796797797798 /// Get the subscription options for the client.
798799 fn subscription_opts(&self) -> impl Future<Output = SubscriptionOptions<'_>> {
···847848/// or when you want to handle auth manually via headers.
848849pub struct BasicSubscriptionClient<W: WebSocketClient> {
849850 client: W,
850850- base_uri: Url,
851851+ base_uri: CowStr<'static>,
851852 opts: SubscriptionOptions<'static>,
852853}
853854854855impl<W: WebSocketClient> BasicSubscriptionClient<W> {
855856 /// Create a new basic subscription client with the given WebSocket client and base URI.
856857 pub fn new(client: W, base_uri: Url) -> Self {
858858+ let base_uri = base_uri.as_str().trim_end_matches("/");
857859 Self {
858860 client,
859859- base_uri,
861861+ base_uri: base_uri.to_cowstr().into_static(),
860862 opts: SubscriptionOptions::default(),
861863 }
862864 }
···890892}
891893892894impl<W: WebSocketClient> SubscriptionClient for BasicSubscriptionClient<W> {
893893- async fn base_uri(&self) -> Url {
895895+ async fn base_uri(&self) -> CowStr<'static> {
894896 self.base_uri.clone()
895897 }
896898···934936 Self: Sync,
935937 {
936938 let base = self.base_uri().await;
939939+ let base = Url::parse(&base).expect("Failed to parse base URL");
937940 self.subscription(base)
938941 .with_options(opts)
939942 .subscribe(params)
···950953 Sub: XrpcSubscription + Send + Sync,
951954 {
952955 let base = self.base_uri().await;
956956+ let base = Url::parse(&base).expect("Failed to parse base URL");
953957 self.subscription(base)
954958 .with_options(opts)
955959 .subscribe(params)