pub struct HeyoClient { /* private fields */ }Implementations§
Source§impl HeyoClient
impl HeyoClient
pub fn new(opts: HeyoClientOptions) -> Result<Self, HeyoError>
Sourcepub fn local() -> Result<Self, HeyoError>
pub fn local() -> Result<Self, HeyoError>
Build a client targeting a local heyvm API at DEFAULT_LOCAL_BASE_URL
(http://127.0.0.1:34099). No auth is sent — a same-machine daemon runs
without JWT_SECRET and skips authentication. Use HeyoClient::local_at
for a non-default address. The local API understands the same cloud HTTP
dialect via its compatibility routes, so the full SDK surface works.
Sourcepub fn local_at(base_url: impl Into<String>) -> Result<Self, HeyoError>
pub fn local_at(base_url: impl Into<String>) -> Result<Self, HeyoError>
Like HeyoClient::local but targets an explicit base URL — e.g. a port
some other component bound for you (an iroh tunnel, an SSH forward).
Sourcepub async fn connect_p2p(
ticket: &str,
relay: Option<&str>,
api_key: Option<String>,
) -> Result<Self, HeyoError>
pub async fn connect_p2p( ticket: &str, relay: Option<&str>, api_key: Option<String>, ) -> Result<Self, HeyoError>
Connect directly to a remote heyvm daemon over iroh P2P, bypassing the
cloud data path. ticket is the daemon’s connection_url (fetch it from
the cloud via GET /me/daemons/{id}/connection-ticket); relay is an
optional iroh relay override for NAT traversal. A background task pumps
the tunnel for the client’s lifetime and is torn down when the client
(and all its clones) drop.
The client’s base_url is set to the local TCP port the tunnel binds, so
every subsequent SDK call rides the P2P link. api_key is forwarded as
the bearer to the daemon (which may run with auth enabled); pass None
when the daemon is unauthenticated.
pub fn base_url(&self) -> &str
Sourcepub async fn request<T: DeserializeOwned>(
&self,
method: Method,
path: &str,
body: Option<&(impl Serialize + ?Sized)>,
opts: RequestOptions,
) -> Result<T, HeyoError>
pub async fn request<T: DeserializeOwned>( &self, method: Method, path: &str, body: Option<&(impl Serialize + ?Sized)>, opts: RequestOptions, ) -> Result<T, HeyoError>
Issue a request and deserialize the JSON response.
Sourcepub async fn request_bytes(
&self,
method: Method,
path: &str,
body: Option<&(impl Serialize + ?Sized)>,
opts: RequestOptions,
) -> Result<Vec<u8>, HeyoError>
pub async fn request_bytes( &self, method: Method, path: &str, body: Option<&(impl Serialize + ?Sized)>, opts: RequestOptions, ) -> Result<Vec<u8>, HeyoError>
Like request but returns the raw response bytes (used by binary
endpoints like /sqlite-databases/:id/file).
Sourcepub async fn raw_request(
&self,
method: Method,
path: &str,
body: Option<&(impl Serialize + ?Sized)>,
opts: RequestOptions,
) -> Result<Response, HeyoError>
pub async fn raw_request( &self, method: Method, path: &str, body: Option<&(impl Serialize + ?Sized)>, opts: RequestOptions, ) -> Result<Response, HeyoError>
Issue the request and return the raw reqwest::Response. Use this
when you need response headers (e.g. checkout’s
X-Heyo-Data-Version) or want to stream the body.
Trait Implementations§
Source§impl Clone for HeyoClient
impl Clone for HeyoClient
Source§fn clone(&self) -> HeyoClient
fn clone(&self) -> HeyoClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more