pub struct GatewayConfig {
    pub access_key: String,
    pub endpoint: String,
    pub region: String,
    /* private fields */
}

Fields§

§access_key: String§endpoint: String§region: String

Implementations§

Examples found in repository?
src/gateway.rs (lines 18-23)
17
18
19
20
21
22
23
24
25
    pub fn new(creds: GatewayCreds, region: S3Region) -> Self {
        let cnf = GatewayConfig::new(
            creds.access_key.clone(),
            creds.secret_key,
            region.endpoint(),
            region.region(),
        );
        Self { cnf }
    }
More examples
Hide additional examples
src/config/mod.rs (line 70)
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
        pub fn partial_env(
            access_key: Option<&str>,
            secret_key: Option<&str>,
            endpoint: String,
            region: String,
        ) -> AsyncResult<Self> {
            let access_key = std::env::var(access_key.unwrap_or("S3_ACCESS_KEY"))?;
            let secret_key = std::env::var(secret_key.unwrap_or("S3_SECRET_KEY"))?;
            Ok(Self::new(access_key, secret_key, endpoint, region))
        }
        pub fn credentials(&self) -> Credentials {
            let cred = GatewayCreds::new(self.access_key.clone(), self.secret_key.clone());
            cred.try_into().ok().unwrap()
        }
        pub fn region(&self) -> Region {
            Region::Custom {
                endpoint: self.endpoint.clone(),
                region: self.region.clone(),
            }
        }
    }

    impl std::convert::From<&GatewayCreds> for GatewayConfig {
        fn from(data: &GatewayCreds) -> Self {
            let region = S3Region::default();
            Self::new(
                data.access_key.clone(),
                data.secret_key.clone(),
                region.endpoint(),
                region.region(),
            )
        }
    }

    impl std::convert::From<&S3Region> for GatewayConfig {
        fn from(data: &S3Region) -> Self {
            let cred = GatewayCreds::default();
            Self::new(
                cred.access_key.clone(),
                cred.secret_key,
                data.endpoint(),
                data.region(),
            )
        }
Examples found in repository?
src/config/mod.rs (lines 110-115)
109
110
111
112
113
114
115
116
117
118
        fn default() -> Self {
            Self::partial_env(
                None,
                None,
                "https://gateway.storjshare.io".to_string(),
                "us-east-1".to_string(),
            )
            .ok()
            .unwrap()
        }
Examples found in repository?
src/contexts/context.rs (line 20)
19
20
21
    pub fn credentials(&self) -> s3::creds::Credentials {
        self.cnf.credentials()
    }
Examples found in repository?
src/contexts/context.rs (line 23)
22
23
24
    pub fn region(&self) -> s3::Region {
        self.cnf.region()
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Converts to this type from a reference to the input type.
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more