Skip to main content

S3Config

Struct S3Config 

Source
#[non_exhaustive]
pub struct S3Config { pub xml_max_body_size: usize, pub post_object_max_file_size: u64, pub form_max_field_size: usize, pub form_max_fields_size: usize, pub form_max_parts: usize, pub presigned_url_max_skew_time_secs: u32, pub normalize_forward_slash_path: bool, }
Expand description

S3 Service Configuration.

Contains configurable parameters for the S3 service with sensible defaults. The configuration is immutable after creation.

Use with StaticConfigProvider or HotReloadConfigProvider.

§Example

use std::sync::Arc;
use s3s::config::{S3Config, S3ConfigProvider, StaticConfigProvider, HotReloadConfigProvider};

let mut config = S3Config::default();
config.xml_max_body_size = 10 * 1024 * 1024;

// Wrap in StaticConfigProvider for immutable config
let static_provider = Arc::new(StaticConfigProvider::new(Arc::new(config.clone())));
let snapshot = static_provider.snapshot();
assert_eq!(snapshot.xml_max_body_size, 10 * 1024 * 1024);

// Or wrap in HotReloadConfigProvider for runtime updates
let hot_config = Arc::new(HotReloadConfigProvider::new(Arc::new(config)));
let snapshot = hot_config.snapshot();
assert_eq!(snapshot.xml_max_body_size, 10 * 1024 * 1024);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§xml_max_body_size: usize

Maximum size for XML body payloads in bytes.

This limit prevents unbounded memory allocation for operations that require the full body in memory (e.g., XML parsing).

Default: 20 MB (20 * 1024 * 1024)

§post_object_max_file_size: u64

Maximum file size for POST object in bytes.

S3 has a 5GB limit for single PUT object, so this is a reasonable default.

Default: 5 GB (5 * 1024 * 1024 * 1024)

§form_max_field_size: usize

Maximum size per form field in bytes.

This prevents denial-of-service attacks via oversized individual fields.

Default: 1 MB (1024 * 1024)

§form_max_fields_size: usize

Maximum total size for all form fields combined in bytes.

This prevents denial-of-service attacks via accumulation of many fields.

Default: 20 MB (20 * 1024 * 1024)

§form_max_parts: usize

Maximum number of parts in multipart form.

This prevents denial-of-service attacks via excessive part count.

Default: 1000

§presigned_url_max_skew_time_secs: u32

Maximum allowed time skew for presigned URLs in seconds.

This allows requests that are up to this many seconds in the future to account for clock skew between the client and server.

Default: 900 (15 minutes)

§normalize_forward_slash_path: bool

Whether to normalize forward slashes in object keys.

If enabled, multiple consecutive slashes will be treated as a single slash:

  • If the path does not start with /, no normalization is performed.
  • If the path starts with /, normalization:
    • removes all leading slashes (unless the entire path is one or more /)
    • replaces consecutive internal slashes with a single slash
    • reduces one or more trailing slashes to a single trailing slash
  • Examples:
    • “/” -> “/”
    • “/keyname” -> “keyname”
    • “//keyname” -> “keyname”
    • “//keyname/” -> “keyname/”
    • “//dir////keyname” -> “dir/keyname”
    • “dir///sub//file” -> “dir///sub//file”
    • “/dir///sub//file” -> “dir/sub/file”

Default: false

Trait Implementations§

Source§

impl Clone for S3Config

Source§

fn clone(&self) -> S3Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for S3Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for S3Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for S3Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for S3Config

Source§

impl PartialEq for S3Config

Source§

fn eq(&self, other: &S3Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for S3Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for S3Config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromExt for T

Source§

fn from_<T>(t: T) -> Self
where Self: From<T>,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoExt for T

Source§

fn into_<T>(self) -> T
where Self: Into<T>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T> TryFromExt for T

Source§

fn try_from_<T>(t: T) -> Result<Self, Self::Error>
where Self: TryFrom<T>,

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TryIntoExt for T

Source§

fn try_into_<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more