pub struct Client { /* private fields */ }Expand description
Top-level client. Cheap to clone (everything inside is Arc-shared).
Implementations§
Source§impl Client
impl Client
pub async fn capabilities(&self) -> Result<CapabilitiesResponse, Error>
Sourcepub fn cdp(&self, method: impl Into<String>) -> CdpBuilder
pub fn cdp(&self, method: impl Into<String>) -> CdpBuilder
Build a raw CDP request. Returns a crate::sdk::cdp::CdpBuilder.
Source§impl Client
impl Client
Sourcepub fn connect(endpoint: &str) -> Result<Self, Error>
pub fn connect(endpoint: &str) -> Result<Self, Error>
Parse an endpoint string and return a Client bound to it. No network
I/O — that happens on the first fetch / health / capabilities call.
Sourcepub fn http_only() -> Result<Self, Error>
pub fn http_only() -> Result<Self, Error>
Build a lightweight client for HTTP-only fetches. It has no host
endpoint and never probes /profile; browser-backed operations return
a structured unavailable error.
Sourcepub fn with_token(self, token: impl Into<String>) -> Self
pub fn with_token(self, token: impl Into<String>) -> Self
Attach a bearer token; sent as Authorization: Bearer <token> on
HTTP requests and as ?token_secret=<token> on the CDP WebSocket upgrade.
Sourcepub fn with_profile(self, profile: impl Into<String>) -> Self
pub fn with_profile(self, profile: impl Into<String>) -> Self
Bind this client to a host profile. The name is sent on the /cdp
connection so the host switches its active profile before serving.
Sourcepub async fn close(&self)
pub async fn close(&self)
Close the cached CDP connection, if one has been opened. The next
fetch or cdp call reconnects lazily.
Sourcepub fn fetch(&self, url: impl Into<String>) -> FetchBuilder
pub fn fetch(&self, url: impl Into<String>) -> FetchBuilder
Build a fetch request. Sending the request actually performs the
fetch — Client::fetch(...).send().await.
Sourcepub async fn profile_info(&self) -> Result<Arc<ProfileInfo>, Error>
pub async fn profile_info(&self) -> Result<Arc<ProfileInfo>, Error>
Fetch (and cache) the host’s profile info from GET /profile. The
pipeline calls this to derive the canonical cookie-jar path
(<profile>/cookies.jar.json) and to validate any explicit
--cookie-jar override against the host’s actual profile dir, so
agents cannot accidentally redirect another profile’s session into
their own jar.
Source§impl Client
impl Client
Sourcepub async fn health(&self) -> Result<HealthResponse, Error>
pub async fn health(&self) -> Result<HealthResponse, Error>
Fetch /health. Returns an error wrapped with
ErrorCode::HostUnreachable on transport failure.
Source§impl Client
impl Client
Sourcepub async fn takeover_handoff(
&self,
ttl_s: Option<u64>,
tab_id: Option<&str>,
) -> Result<TakeoverHandoffResponse, Error>
pub async fn takeover_handoff( &self, ttl_s: Option<u64>, tab_id: Option<&str>, ) -> Result<TakeoverHandoffResponse, Error>
Mint a short-lived URL capability for /takeover/*.
Sourcepub async fn takeover_ui_session(&self) -> Result<TakeoverUiSession, Error>
pub async fn takeover_ui_session(&self) -> Result<TakeoverUiSession, Error>
Mint a process-bound upstream credential for an AFUI delivery.
Source§impl Client
impl Client
Sourcepub async fn inline_ephemeral() -> Result<Self, Error>
pub async fn inline_ephemeral() -> Result<Self, Error>
Spawn a private afhttp host listener bound to a random local
port, launch a chromium backend, and connect to it. The host runs
in the same process as a tokio task and is shut down when the
last clone of the returned Client is dropped.
Sourcepub async fn inline_ephemeral_with(config: InlineConfig) -> Result<Self, Error>
pub async fn inline_ephemeral_with(config: InlineConfig) -> Result<Self, Error>
Like inline_ephemeral but with explicit
browser configuration (backend choice and/or binary path). Use this when
auto-discovery can’t find a browser on the host.