Skip to main content
snipp-gg/snipp-rust
crates.io/crates/snipp

Installation

Add to your Cargo.toml:

Getting Started

Regional endpoints

Use with_region to pin the client to a specific regional host. Uploads run at the same speed either way; this controls which region stores your files.

Methods

All methods are async and return Result<T, SnippError>.

get_user(id, options)

Fetch a user by ID. Pass "@me" for the authenticated user.

get_post(code)

Fetch a post by its share code. Team posts are only readable by members of that team, and carry no like_count.

upload(path, options)

Upload a file from disk. privacy defaults to private when omitted.

list_uploads(limit)

List the authenticated user’s recent uploads. Pass Some(N) for limit to control the count (max 1000), or None for the default (30).

edit_upload(code, options)

Edit an existing upload’s title, description, or privacy. Empty strings clear the title or description.

append_upload(code, file_paths)

Add one or more files to an existing album post. The post’s share code, privacy, title, and description are preserved. Albums cap at 50 files total. Requests that would exceed the cap are rejected. New files inherit the post’s privacy. Returned URLs are signed with a 24-hour expiry for private posts.

delete_upload(filename)

Delete an upload by its filename. On albums, only that file is removed; on single-file posts the entire post is deleted.

report_post(code, reason)

Report a post. Pass an empty string to omit the reason (max 200 chars).

Error Handling

All errors are returned as SnippError, which covers API errors, HTTP errors, local input validation, deserialization failures, and IO errors. SnippError::Api carries status, message, and body. body is the parsed JSON error response, or None when the response was not JSON. It carries the fields the API sends alongside error, such as suspended on a suspended user or moderated on a moderated post.