XU XUv0.8.8
中文

API

#github.com/xulang-org/packages/s3

import: s3 #github.com/xulang-org/packages/s3

counts: 7 fns, 21 methods, 3 types, 0 consts, 0 ifaces

S3 & MinIO Compatible Object Storage Driver for Xu Features Standard AWS Signature Version 4 (SigV4) calculation with pure Xu crypto primitives. Works with AWS S3, MinIO, Ceph, Cloudflare R2, and other S3-compatible object storages. Full bucket lifecycle: make_bucket, bucket_exists, remove_bucket. Full object lifecycle: put_object, get_object, remove_object, object_exists.

github.com/xulang-org/packages · 0.1.1 · Install and use

open

XuAPI
pub fn open(endpoint string, access_key string, secret_key string, region string) Client

Purpose

S3 & MinIO Compatible Object Storage Driver for Xu Features Standard AWS Signature Version 4 (SigV4) calculation with pure Xu crypto primitives. Works with AWS S3, MinIO, Ceph, Cloudflare R2, and other S3-compatible object storages. Full bucket lifecycle: make_bucket, bucket_exists, remove_bucket. Full object lifecycle: put_object, get_object, remove_object, object_exists.

Parameters

endpoint string
endpoint (string)
access_key string
access_key (string)
secret_key string
secret_key (string)
region string
region (string)

Returns

Client — a value of this type

open_pool

XuAPI
pub fn open_pool(endpoint string, access_key string, secret_key string, region string, max_idle int) Pool

Purpose

Open pool.

Parameters

endpoint string
endpoint (string)
access_key string
access_key (string)
secret_key string
secret_key (string)
region string
region (string)
max_idle int
max_idle (int)

Returns

Pool — a value of this type

(&mut Client) make_bucket

XuAPI
pub fn (c &mut Client) make_bucket(bucket string) int

Purpose

Method on `&mut Client`: make bucket. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
bucket string
bucket (string)

Returns

int — a value of this type

(&mut Client) bucket_exists

XuAPI
pub fn (c &mut Client) bucket_exists(bucket string) bool

Purpose

Method on `&mut Client`: bucket exists.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
bucket string
bucket (string)

Returns

bool — true or false

(&mut Client) remove_bucket

XuAPI
pub fn (c &mut Client) remove_bucket(bucket string) int

Purpose

Method on `&mut Client`: remove bucket. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
bucket string
bucket (string)

Returns

int — a value of this type

struct Response

XuAPI
pub struct Response {
    pub status_code int
    pub body string
}

Purpose

Public struct `Response`.

Parameters

status_code int
field (int)
body string
body

struct Client

XuAPI
pub struct Client {
    pub host string
    pub port int
    pub access_key string
    pub secret_key string
    pub region string
}

Purpose

Public struct `Client`.

Parameters

host string
host
port int
port
access_key string
field (string)
secret_key string
field (string)
region string
field (string)

new_client

XuAPI
pub fn new_client(endpoint string, access_key string, secret_key string, region string) Client

Purpose

Construct client.

Parameters

endpoint string
endpoint (string)
access_key string
access_key (string)
secret_key string
secret_key (string)
region string
region (string)

Returns

Client — a value of this type

(&mut Client) request

XuAPI
pub fn (c &mut Client) request(method string, path string, body string, content_type string) Response

Purpose

Call `request` on `&mut Client`. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
method string
method (string)
path string
filesystem path (string)
body string
body (string)
content_type string
content_type (string)

Returns

Response — a value of this type

(&mut Client) put_object

XuAPI
pub fn (c &mut Client) put_object(bucket string, key string, data string, content_type string) int

Purpose

Method on `&mut Client`: put object. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
bucket string
bucket (string)
key string
key (string)
data string
data (string)
content_type string
content_type (string)

Returns

int — a value of this type

(&mut Client) get_object

XuAPI
pub fn (c &mut Client) get_object(bucket string, key string) string

Purpose

Method on `&mut Client`: read object. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
bucket string
bucket (string)
key string
key (string)

Returns

string — result string

(&mut Client) remove_object

XuAPI
pub fn (c &mut Client) remove_object(bucket string, key string) int

Purpose

Method on `&mut Client`: remove object. Throws on failure.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
bucket string
bucket (string)
key string
key (string)

Returns

int — a value of this type

(&mut Client) object_exists

XuAPI
pub fn (c &mut Client) object_exists(bucket string, key string) bool

Purpose

Method on `&mut Client`: object exists.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)
bucket string
bucket (string)
key string
key (string)

Returns

bool — true or false

struct Pool

XuAPI
pub struct Pool {
    pub host string
    pub port int
    pub endpoint string
    pub access_key string
    pub secret_key string
    pub region string
    pub state chan pool.State
    pub max_idle int
}

Purpose

Connection Pool for S3 & MinIO Compatible Object Storage. Manages reusable TCP/HTTP socket connections.

Parameters

host string
host
port int
port
endpoint string
field (string)
access_key string
field (string)
secret_key string
field (string)
region string
field (string)
state chan pool.State
field (channel; type chan pool.State)
max_idle int
field (int)

new_pool

XuAPI
pub fn new_pool(endpoint string, access_key string, secret_key string, region string, max_idle int) Pool

Purpose

Construct pool.

Parameters

endpoint string
endpoint (string)
access_key string
access_key (string)
secret_key string
secret_key (string)
region string
region (string)
max_idle int
max_idle (int)

Returns

Pool — a value of this type

(&Pool) get

XuAPI
pub fn (p &Pool) get() Client

Purpose

Call `get` on `&Pool`.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

Client — a value of this type

(&Pool) dup

XuAPI
pub fn (p &Pool) dup() Pool

Purpose

Shares sockets and close state; clones configuration strings.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

Pool — a value of this type

(&Pool) get_conn

XuAPI
pub fn (p &Pool) get_conn() int

Purpose

Method on `&Pool`: read conn.

Parameters

p &Pool
receiver &Pool (borrow)

Returns

int — a value of this type

(&Pool) put_conn

XuAPI
pub fn (p &Pool) put_conn(fd int)

Purpose

Method on `&Pool`: put connection.

Parameters

p &Pool
receiver &Pool (borrow)
fd int
file descriptor (int)

(&Pool) discard_conn

XuAPI
pub fn (p &Pool) discard_conn(fd int)

Purpose

Method on `&Pool`: discard connection.

Parameters

p &Pool
receiver &Pool (borrow)
fd int
file descriptor (int)

(&Pool) make_bucket

XuAPI
pub fn (p &Pool) make_bucket(bucket string) int

Purpose

Method on `&Pool`: make bucket. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
bucket string
bucket (string)

Returns

int — a value of this type

(&Pool) bucket_exists

XuAPI
pub fn (p &Pool) bucket_exists(bucket string) bool

Purpose

Method on `&Pool`: bucket exists.

Parameters

p &Pool
receiver &Pool (borrow)
bucket string
bucket (string)

Returns

bool — true or false

(&Pool) remove_bucket

XuAPI
pub fn (p &Pool) remove_bucket(bucket string) int

Purpose

Method on `&Pool`: remove bucket. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
bucket string
bucket (string)

Returns

int — a value of this type

(&Pool) put_object

XuAPI
pub fn (p &Pool) put_object(bucket string, key string, data string, content_type string) int

Purpose

Method on `&Pool`: put object. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
bucket string
bucket (string)
key string
key (string)
data string
data (string)
content_type string
content_type (string)

Returns

int — a value of this type

(&Pool) get_object

XuAPI
pub fn (p &Pool) get_object(bucket string, key string) string

Purpose

Method on `&Pool`: read object. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
bucket string
bucket (string)
key string
key (string)

Returns

string — result string

(&Pool) remove_object

XuAPI
pub fn (p &Pool) remove_object(bucket string, key string) int

Purpose

Method on `&Pool`: remove object. Throws on failure.

Parameters

p &Pool
receiver &Pool (borrow)
bucket string
bucket (string)
key string
key (string)

Returns

int — a value of this type

(&Pool) object_exists

XuAPI
pub fn (p &Pool) object_exists(bucket string, key string) bool

Purpose

Method on `&Pool`: object exists.

Parameters

p &Pool
receiver &Pool (borrow)
bucket string
bucket (string)
key string
key (string)

Returns

bool — true or false

(&Pool) close

XuAPI
pub fn (p &Pool) close()

Purpose

Method on `&Pool`: close the resource.

Parameters

p &Pool
receiver &Pool (borrow)

sha256_hex

XuAPI
pub fn sha256_hex(data string) string

Purpose

Sha256 hex.

Parameters

data string
data (string)

Returns

string — result string

hmac_hex

XuAPI
pub fn hmac_hex(key string, data string) string

Purpose

Hmac hex.

Parameters

key string
key (string)
data string
data (string)

Returns

string — result string

compute_auth_header

XuAPI
pub fn compute_auth_header( method string, path string, host string, access_key string, secret_key string, region string, amz_date string, date_stamp string, payload_hash string ) string

Purpose

Compute auth header.

Parameters

method string
method (string)
path string
filesystem path (string)
host string
host (string)
access_key string
access_key (string)
secret_key string
secret_key (string)
region string
region (string)
amz_date string
amz_date (string)
date_stamp string
date_stamp (string)
payload_hash string
payload_hash (string)

Returns

string — result string