pub struct LsClient { /* private fields */ }Expand description
HTTP/HTTPS client tailored for the LocalSend v2.2 wire protocol.
Implementations§
Source§impl LsClient
impl LsClient
Sourcepub fn new(config: LsClientConfig) -> Result<Self, ClientError>
pub fn new(config: LsClientConfig) -> Result<Self, ClientError>
Constructs a new LsClient with the provided configuration.
Sourcepub fn target_fingerprint(&self) -> Option<&str>
pub fn target_fingerprint(&self) -> Option<&str>
The pinned target fingerprint, if any.
Sourcepub async fn get_info(
&self,
base_url: &str,
) -> Result<InfoResponseDtoV2, ClientError>
pub async fn get_info( &self, base_url: &str, ) -> Result<InfoResponseDtoV2, ClientError>
Fetches remote peer info via GET /api/localsend/v2/info (or /api/localsend/v1/info).
Sourcepub async fn register(
&self,
base_url: &str,
dto: &RegisterDtoV2,
) -> Result<RegisterResponseDtoV2, ClientError>
pub async fn register( &self, base_url: &str, dto: &RegisterDtoV2, ) -> Result<RegisterResponseDtoV2, ClientError>
Registers this device with the remote peer via POST /api/localsend/v2/register.
Sourcepub async fn prepare_upload(
&self,
base_url: &str,
request: &PrepareUploadRequestDtoV2,
pin: Option<&str>,
) -> Result<PrepareUploadResponseDtoV2, ClientError>
pub async fn prepare_upload( &self, base_url: &str, request: &PrepareUploadRequestDtoV2, pin: Option<&str>, ) -> Result<PrepareUploadResponseDtoV2, ClientError>
Initiates a transfer session via POST /api/localsend/v2/prepare-upload.
Sourcepub async fn upload_file<B>(
&self,
base_url: &str,
session_id: &str,
file_id: &str,
token: &str,
body: B,
content_length: u64,
) -> Result<(), ClientError>
pub async fn upload_file<B>( &self, base_url: &str, session_id: &str, file_id: &str, token: &str, body: B, content_length: u64, ) -> Result<(), ClientError>
Uploads an individual file stream via POST /api/localsend/v2/upload?sessionId=...&fileId=...&token=....
Sourcepub async fn cancel_session(
&self,
base_url: &str,
session_id: &str,
) -> Result<(), ClientError>
pub async fn cancel_session( &self, base_url: &str, session_id: &str, ) -> Result<(), ClientError>
Cancels an active or pending session via POST /api/localsend/v2/cancel?sessionId=....
Sourcepub async fn prepare_download(
&self,
base_url: &str,
session_id: Option<&str>,
pin: Option<&str>,
) -> Result<PrepareDownloadResponseDtoV2, ClientError>
pub async fn prepare_download( &self, base_url: &str, session_id: Option<&str>, pin: Option<&str>, ) -> Result<PrepareDownloadResponseDtoV2, ClientError>
Prepares to download files from a sender hosting them (Browser Download / Reverse Transfer API).
Calls POST /api/localsend/v2/prepare-download.
Sourcepub async fn download_file(
&self,
base_url: &str,
session_id: &str,
file_id: &str,
) -> Result<Response, ClientError>
pub async fn download_file( &self, base_url: &str, session_id: &str, file_id: &str, ) -> Result<Response, ClientError>
Downloads a file binary stream from a sender hosting it (Reverse Transfer API).
Calls GET /api/localsend/v2/download?sessionId=...&fileId=....