pub struct Client { /* private fields */ }Expand description
Async client for the Insta360 cloud API.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(cfg: ClientConfig) -> Result<Self>
pub fn new(cfg: ClientConfig) -> Result<Self>
Construct a client from config. Fails only if the TLS/HTTP stack can’t be built.
Sourcepub fn http(&self) -> &Client
pub fn http(&self) -> &Client
Access the underlying reqwest client (used by the download path for the OSS GET, which is not an API-signed request).
Sourcepub async fn profile(&self, session: &Session) -> Result<Profile>
pub async fn profile(&self, session: &Session) -> Result<Profile>
Fetch the authenticated profile
(GET openapi-*/account/v2/getProfile). The account API lives on the
openapi host; data nests the profile under account.
Sourcepub async fn refresh(&self, session: &Session) -> Result<Session>
pub async fn refresh(&self, session: &Session) -> Result<Session>
Renew the session (GET openapi-*/account/v2/refreshToken).
The current token authenticates the call and the API mints a fresh one
in data.token — no separate refresh token is required, so a session can
be rolled forward indefinitely as long as it is renewed before it lapses.
Sourcepub async fn list_media(
&self,
session: &Session,
cursor: PageCursor,
) -> Result<MediaPage>
pub async fn list_media( &self, session: &Session, cursor: PageCursor, ) -> Result<MediaPage>
List cloud media, one page
(GET service-*/cloud/service/media/view/list?pageNumber&pageSize).
Sourcepub async fn media_detail(
&self,
session: &Session,
id: &MediaId,
) -> Result<Media>
pub async fn media_detail( &self, session: &Session, id: &MediaId, ) -> Result<Media>
Fetch full detail for one media item
(GET service-*/cloud/service/media/view/detail?mediaId).
Sourcepub async fn resolve_download(
&self,
session: &Session,
id: &MediaId,
) -> Result<Vec<FilePart>>
pub async fn resolve_download( &self, session: &Session, id: &MediaId, ) -> Result<Vec<FilePart>>
Resolve the signed CDN download URL(s) for a media item
(GET service-*/cloud/service/media/download?mediaId). Returns one
FilePart per file (the response’s data.paths[]).
The resourceKey URLs are short-lived (~24h) — download promptly.
Source§impl Client
impl Client
Sourcepub async fn download_part<W, P>(
&self,
part: &FilePart,
sink: W,
from: u64,
progress: P,
) -> Result<()>
pub async fn download_part<W, P>( &self, part: &FilePart, sink: W, from: u64, progress: P, ) -> Result<()>
Stream one FilePart into sink, resuming from byte from.
from— resume offset; pass 0 for a fresh download. Sent as an HTTPRange: bytes=from-header.progress— invoked as bytes arrive with the running total.
On a 403 (OSS URL expired) the caller should re-resolve_download and
retry with the new URL and the same from.