s3uri: AWS S3 URIs in Rust
s3uri is a Rust library with structs and functions for building and parsing Amazon Web Services S3 URIs.
Installation
Examples
Parsing a URI
s3uri::from_uri parses a string URI and returns a s3uri::S3Uri struct with the bucket name and key set.
let uri = from_uri.unwrap;
assert_eq!;
assert!;
Creating a new URI
To create a new URI from scratch, pass the bucket name to s3uri::from_bucket to get a s3uri::S3Uri struct.
let uri = from_bucket;
assert_eq!;
assert_eq!;
assert!;
Joining keys and key prefixes
Call s3uri::S3Uri::join() to build up the key. Separators will be normalised and added between each segment as-needed.
let images_prefix = from_bucket
.join;
assert_eq!;
let clowns_uri = images_prefix
.join
.join;
assert_eq!;
Check if a key is a prefix
Call s3uri::S3Key::is_prefix() to check if a key is a prefix (i.e. ends with a /) or not.
let images_uri = from_bucket
.join;
assert!;
let clowns_uri = images_uri.join;
assert!;
Key leaf
Call s3uri::S3Key::leaf() to get the segment of the key after the final separator.
let images_uri = from_bucket
.join;
assert_eq!;
let clowns_uri = images_uri
.join
.join;
assert_eq!;
Author
Hello! 👋 I'm Cariad Eccleston. You can find me at cariad.earth, github.com/cariad, linkedin.com/in/cariad and @cariad.earth on Bluesky.