Skip to main content

MaterialProvidersConfig

Struct MaterialProvidersConfig 

Source
#[non_exhaustive]
pub struct MaterialProvidersConfig {}

Implementations§

Source§

impl MaterialProvidersConfig

Source

pub fn builder() -> MaterialProvidersConfigBuilder

Creates a new builder-style object to manufacture MaterialProvidersConfig.

Examples found in repository?
examples/cryptographic_materials_manager/restrict_algorithm_suite/signing_suite_only_cmm.rs (line 34)
33    pub fn new(keyring: KeyringRef) -> Self {
34        let mpl_config = MaterialProvidersConfig::builder().build().unwrap();
35        let mpl = mpl_client::Client::from_conf(mpl_config).unwrap();
36
37        Self {
38            approved_algos: vec![
39                EsdkAlgorithmSuiteId::AlgAes128GcmIv12Tag16HkdfSha256EcdsaP256,
40                EsdkAlgorithmSuiteId::AlgAes192GcmIv12Tag16HkdfSha384EcdsaP384,
41                EsdkAlgorithmSuiteId::AlgAes256GcmIv12Tag16HkdfSha384EcdsaP384,
42                EsdkAlgorithmSuiteId::AlgAes256GcmHkdfSha512CommitKeyEcdsaP384,
43            ],
44            // Create a DefaultCryptographicMaterialsManager to facilitate
45            // GetEncryptionMaterials and DecryptionMaterials
46            // after this CMM approves the Algorithm Suite.
47            cmm: tokio::task::block_in_place(|| {
48                tokio::runtime::Handle::current().block_on(async {
49                    mpl.create_default_cryptographic_materials_manager()
50                        .keyring(keyring)
51                        .send()
52                        .await
53                })
54            })
55            .unwrap(),
56        }
57    }
More examples
Hide additional examples
examples/keyring/aws_kms_keyring_example.rs (line 65)
30pub async fn encrypt_and_decrypt_with_keyring(
31    example_data: &str,
32    kms_key_id: &str,
33) -> Result<(), crate::BoxError> {
34    // 1. Instantiate the encryption SDK client.
35    // This builds the default client with the RequireEncryptRequireDecrypt commitment policy,
36    // which enforces that this client only encrypts using committing algorithm suites and enforces
37    // that this client will only decrypt encrypted messages that were created with a committing
38    // algorithm suite.
39    let esdk_config = AwsEncryptionSdkConfig::builder().build()?;
40    let esdk_client = esdk_client::Client::from_conf(esdk_config)?;
41
42    // 2. Create a KMS client.
43    let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
44    let kms_client = aws_sdk_kms::Client::new(&sdk_config);
45
46    // 3. Create encryption context.
47    // Remember that your encryption context is NOT SECRET.
48    // For more information, see
49    // https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#encryption-context
50    let encryption_context = HashMap::from([
51        ("encryption".to_string(), "context".to_string()),
52        ("is not".to_string(), "secret".to_string()),
53        ("but adds".to_string(), "useful metadata".to_string()),
54        (
55            "that can help you".to_string(),
56            "be confident that".to_string(),
57        ),
58        (
59            "the data you are handling".to_string(),
60            "is what you think it is".to_string(),
61        ),
62    ]);
63
64    // 4. Create a KMS keyring
65    let mpl_config = MaterialProvidersConfig::builder().build()?;
66    let mpl = mpl_client::Client::from_conf(mpl_config)?;
67
68    let kms_keyring = mpl
69        .create_aws_kms_keyring()
70        .kms_key_id(kms_key_id)
71        .kms_client(kms_client)
72        .send()
73        .await?;
74
75    // 5. Encrypt the data with the encryption_context
76    let plaintext = example_data.as_bytes();
77
78    let encryption_response = esdk_client
79        .encrypt()
80        .plaintext(plaintext)
81        .keyring(kms_keyring.clone())
82        .encryption_context(encryption_context.clone())
83        .send()
84        .await?;
85
86    let ciphertext = encryption_response
87        .ciphertext
88        .expect("Unable to unwrap ciphertext from encryption response");
89
90    // 6. Demonstrate that the ciphertext and plaintext are different.
91    // (This is an example for demonstration; you do not need to do this in your own code.)
92    assert_ne!(
93        ciphertext,
94        aws_smithy_types::Blob::new(plaintext),
95        "Ciphertext and plaintext data are the same. Invalid encryption"
96    );
97
98    // 7. Decrypt your encrypted data using the same keyring you used on encrypt.
99    let decryption_response = esdk_client
100        .decrypt()
101        .ciphertext(ciphertext)
102        .keyring(kms_keyring)
103        // Provide the encryption context that was supplied to the encrypt method
104        .encryption_context(encryption_context)
105        .send()
106        .await?;
107
108    let decrypted_plaintext = decryption_response
109        .plaintext
110        .expect("Unable to unwrap plaintext from decryption response");
111
112    // 8. Demonstrate that the decrypted plaintext is identical to the original plaintext.
113    // (This is an example for demonstration; you do not need to do this in your own code.)
114    assert_eq!(
115        decrypted_plaintext,
116        aws_smithy_types::Blob::new(plaintext),
117        "Decrypted plaintext should be identical to the original plaintext. Invalid decryption"
118    );
119
120    println!("KMS Keyring Example Completed Successfully");
121
122    Ok(())
123}
examples/keyring/aws_kms_rsa_keyring_example.rs (line 64)
28pub async fn encrypt_and_decrypt_with_keyring(
29    example_data: &str,
30    kms_rsa_key_id: &str,
31    kms_rsa_public_key: &str,
32) -> Result<(), crate::BoxError> {
33    // 1. Instantiate the encryption SDK client.
34    // This builds the default client with the RequireEncryptRequireDecrypt commitment policy,
35    // which enforces that this client only encrypts using committing algorithm suites and enforces
36    // that this client will only decrypt encrypted messages that were created with a committing
37    // algorithm suite.
38    let esdk_config = AwsEncryptionSdkConfig::builder().build()?;
39    let esdk_client = esdk_client::Client::from_conf(esdk_config)?;
40
41    // 2. Create a KMS client.
42    let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
43    let kms_client = aws_sdk_kms::Client::new(&sdk_config);
44
45    // 3. Create encryption context.
46    // Remember that your encryption context is NOT SECRET.
47    // For more information, see
48    // https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#encryption-context
49    let encryption_context = HashMap::from([
50        ("encryption".to_string(), "context".to_string()),
51        ("is not".to_string(), "secret".to_string()),
52        ("but adds".to_string(), "useful metadata".to_string()),
53        (
54            "that can help you".to_string(),
55            "be confident that".to_string(),
56        ),
57        (
58            "the data you are handling".to_string(),
59            "is what you think it is".to_string(),
60        ),
61    ]);
62
63    // 4. Create a KMS RSA keyring
64    let mpl_config = MaterialProvidersConfig::builder().build()?;
65    let mpl = mpl_client::Client::from_conf(mpl_config)?;
66
67    // For more information on the allowed encryption algorithms, please see
68    // https://docs.aws.amazon.com/kms/latest/developerguide/asymmetric-key-specs.html#key-spec-rsa
69    let kms_rsa_keyring = mpl
70        .create_aws_kms_rsa_keyring()
71        .kms_key_id(kms_rsa_key_id)
72        .public_key(aws_smithy_types::Blob::new(kms_rsa_public_key))
73        .encryption_algorithm(aws_sdk_kms::types::EncryptionAlgorithmSpec::RsaesOaepSha256)
74        .kms_client(kms_client)
75        .send()
76        .await?;
77
78    // 5. Encrypt the data with the encryption_context
79    let plaintext = example_data.as_bytes();
80
81    let encryption_response = esdk_client
82        .encrypt()
83        .plaintext(plaintext)
84        .keyring(kms_rsa_keyring.clone())
85        .encryption_context(encryption_context.clone())
86        .algorithm_suite_id(EsdkAlgorithmSuiteId::AlgAes256GcmHkdfSha512CommitKey)
87        .send()
88        .await?;
89
90    let ciphertext = encryption_response
91        .ciphertext
92        .expect("Unable to unwrap ciphertext from encryption response");
93
94    // 6. Demonstrate that the ciphertext and plaintext are different.
95    // (This is an example for demonstration; you do not need to do this in your own code.)
96    assert_ne!(
97        ciphertext,
98        aws_smithy_types::Blob::new(plaintext),
99        "Ciphertext and plaintext data are the same. Invalid encryption"
100    );
101
102    // 7. Decrypt your encrypted data using the same keyring you used on encrypt.
103    let decryption_response = esdk_client
104        .decrypt()
105        .ciphertext(ciphertext)
106        .keyring(kms_rsa_keyring)
107        // Provide the encryption context that was supplied to the encrypt method
108        .encryption_context(encryption_context)
109        .send()
110        .await?;
111
112    let decrypted_plaintext = decryption_response
113        .plaintext
114        .expect("Unable to unwrap plaintext from decryption response");
115
116    // 8. Demonstrate that the decrypted plaintext is identical to the original plaintext.
117    // (This is an example for demonstration; you do not need to do this in your own code.)
118    assert_eq!(
119        decrypted_plaintext,
120        aws_smithy_types::Blob::new(plaintext),
121        "Decrypted plaintext should be identical to the original plaintext. Invalid decryption"
122    );
123
124    println!("KMS RSA Keyring Example Completed Successfully");
125
126    Ok(())
127}
examples/keyring/raw_aes_keyring_example.rs (line 74)
34pub async fn encrypt_and_decrypt_with_keyring(example_data: &str) -> Result<(), crate::BoxError> {
35    // 1. Instantiate the encryption SDK client.
36    // This builds the default client with the RequireEncryptRequireDecrypt commitment policy,
37    // which enforces that this client only encrypts using committing algorithm suites and enforces
38    // that this client will only decrypt encrypted messages that were created with a committing
39    // algorithm suite.
40    let esdk_config = AwsEncryptionSdkConfig::builder().build()?;
41    let esdk_client = esdk_client::Client::from_conf(esdk_config)?;
42
43    // 2. The key namespace and key name are defined by you.
44    // and are used by the Raw AES keyring to determine
45    // whether it should attempt to decrypt an encrypted data key.
46    // For more information, see
47    // https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-raw-aes-keyring.html
48    let key_namespace: &str = "my-key-namespace";
49    let key_name: &str = "my-aes-key-name";
50
51    // 3. Create encryption context.
52    // Remember that your encryption context is NOT SECRET.
53    // For more information, see
54    // https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#encryption-context
55    let encryption_context = HashMap::from([
56        ("encryption".to_string(), "context".to_string()),
57        ("is not".to_string(), "secret".to_string()),
58        ("but adds".to_string(), "useful metadata".to_string()),
59        (
60            "that can help you".to_string(),
61            "be confident that".to_string(),
62        ),
63        (
64            "the data you are handling".to_string(),
65            "is what you think it is".to_string(),
66        ),
67    ]);
68
69    // 4. Generate a 256-bit AES key to use with your keyring.
70    // In practice, you should get this key from a secure key management system such as an HSM.
71    let aes_key_bytes = generate_aes_key_bytes();
72
73    // 5. Create a Raw AES Keyring
74    let mpl_config = MaterialProvidersConfig::builder().build()?;
75    let mpl = mpl_client::Client::from_conf(mpl_config)?;
76
77    let raw_aes_keyring = mpl
78        .create_raw_aes_keyring()
79        .key_name(key_name)
80        .key_namespace(key_namespace)
81        .wrapping_key(aes_key_bytes)
82        .wrapping_alg(AesWrappingAlg::AlgAes256GcmIv12Tag16)
83        .send()
84        .await?;
85
86    // 6. Encrypt the data with the encryption_context
87    let plaintext = example_data.as_bytes();
88
89    let encryption_response = esdk_client
90        .encrypt()
91        .plaintext(plaintext)
92        .keyring(raw_aes_keyring.clone())
93        .encryption_context(encryption_context.clone())
94        .send()
95        .await?;
96
97    let ciphertext = encryption_response
98        .ciphertext
99        .expect("Unable to unwrap ciphertext from encryption response");
100
101    // 7. Demonstrate that the ciphertext and plaintext are different.
102    // (This is an example for demonstration; you do not need to do this in your own code.)
103    assert_ne!(
104        ciphertext,
105        aws_smithy_types::Blob::new(plaintext),
106        "Ciphertext and plaintext data are the same. Invalid encryption"
107    );
108
109    // 8. Decrypt your encrypted data using the same keyring you used on encrypt.
110    let decryption_response = esdk_client
111        .decrypt()
112        .ciphertext(ciphertext)
113        .keyring(raw_aes_keyring)
114        // Provide the encryption context that was supplied to the encrypt method
115        .encryption_context(encryption_context)
116        .send()
117        .await?;
118
119    let decrypted_plaintext = decryption_response
120        .plaintext
121        .expect("Unable to unwrap plaintext from decryption response");
122
123    // 9. Demonstrate that the decrypted plaintext is identical to the original plaintext.
124    // (This is an example for demonstration; you do not need to do this in your own code.)
125    assert_eq!(
126        decrypted_plaintext,
127        aws_smithy_types::Blob::new(plaintext),
128        "Decrypted plaintext should be identical to the original plaintext. Invalid decryption"
129    );
130
131    println!("Raw AES Keyring Example Completed Successfully");
132
133    Ok(())
134}
examples/set_encryption_algorithm_suite_example.rs (line 91)
51pub async fn encrypt_and_decrypt_with_keyring(example_data: &str) -> Result<(), crate::BoxError> {
52    // 1. Instantiate the encryption SDK client.
53    // This builds the default client with the RequireEncryptRequireDecrypt commitment policy,
54    // which enforces that this client only encrypts using committing algorithm suites and enforces
55    // that this client will only decrypt encrypted messages that were created with a committing
56    // algorithm suite.
57    let esdk_config = AwsEncryptionSdkConfig::builder().build()?;
58    let esdk_client = esdk_client::Client::from_conf(esdk_config)?;
59
60    // 2. The key namespace and key name are defined by you.
61    // and are used by the Raw AES keyring to determine
62    // whether it should attempt to decrypt an encrypted data key.
63    // For more information, see
64    // https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-raw-aes-keyring.html
65    let key_namespace: &str = "my-key-namespace";
66    let key_name: &str = "my-aes-key-name";
67
68    // 3. Create encryption context.
69    // Remember that your encryption context is NOT SECRET.
70    // For more information, see
71    // https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#encryption-context
72    let encryption_context = HashMap::from([
73        ("encryption".to_string(), "context".to_string()),
74        ("is not".to_string(), "secret".to_string()),
75        ("but adds".to_string(), "useful metadata".to_string()),
76        (
77            "that can help you".to_string(),
78            "be confident that".to_string(),
79        ),
80        (
81            "the data you are handling".to_string(),
82            "is what you think it is".to_string(),
83        ),
84    ]);
85
86    // 4. Generate a 256-bit AES key to use with your keyring.
87    // In practice, you should get this key from a secure key management system such as an HSM.
88    let aes_key_bytes = generate_aes_key_bytes();
89
90    // 5. Create a Raw AES Keyring
91    let mpl_config = MaterialProvidersConfig::builder().build()?;
92    let mpl = mpl_client::Client::from_conf(mpl_config)?;
93
94    // The wrapping algorithm here is NOT the algorithm suite we set in this example.
95    let raw_aes_keyring = mpl
96        .create_raw_aes_keyring()
97        .key_name(key_name)
98        .key_namespace(key_namespace)
99        .wrapping_key(aes_key_bytes)
100        .wrapping_alg(AesWrappingAlg::AlgAes256GcmIv12Tag16)
101        .send()
102        .await?;
103
104    // 6. Encrypt the data with the encryption_context
105    let plaintext = example_data.as_bytes();
106
107    // This is the important step in this example where we specify the algorithm suite
108    // you want to use for encrypting your data
109    let encryption_response = esdk_client
110        .encrypt()
111        .plaintext(plaintext)
112        .keyring(raw_aes_keyring.clone())
113        .encryption_context(encryption_context.clone())
114        .algorithm_suite_id(AlgAes256GcmHkdfSha512CommitKey)
115        .send()
116        .await?;
117
118    let ciphertext = encryption_response
119        .ciphertext
120        .expect("Unable to unwrap ciphertext from encryption response");
121
122    // 7. Demonstrate that the ciphertext and plaintext are different.
123    // (This is an example for demonstration; you do not need to do this in your own code.)
124    assert_ne!(
125        ciphertext,
126        aws_smithy_types::Blob::new(plaintext),
127        "Ciphertext and plaintext data are the same. Invalid encryption"
128    );
129
130    // 8. Decrypt your encrypted data using the same keyring you used on encrypt.
131    let decryption_response = esdk_client
132        .decrypt()
133        .ciphertext(ciphertext)
134        .keyring(raw_aes_keyring)
135        // Provide the encryption context that was supplied to the encrypt method
136        .encryption_context(encryption_context)
137        .send()
138        .await?;
139
140    let decrypted_plaintext = decryption_response
141        .plaintext
142        .expect("Unable to unwrap plaintext from decryption response");
143
144    // 9. Demonstrate that the decrypted plaintext is identical to the original plaintext.
145    // (This is an example for demonstration; you do not need to do this in your own code.)
146    assert_eq!(
147        decrypted_plaintext,
148        aws_smithy_types::Blob::new(plaintext),
149        "Decrypted plaintext should be identical to the original plaintext. Invalid decryption"
150    );
151
152    println!("Set Encryption Algorithm Suite Example Completed Successfully");
153
154    Ok(())
155}
examples/set_commitment_policy_example.rs (line 74)
34pub async fn encrypt_and_decrypt_with_keyring(
35    example_data: &str,
36    kms_key_id: &str,
37) -> Result<(), crate::BoxError> {
38    // 1. Instantiate the encryption SDK client.
39    // This example builds the client with the ForbidEncryptAllowDecrypt commitment policy,
40    // which enforces that this client cannot encrypt with key commitment
41    // and it can decrypt ciphertexts encrypted with or without key commitment.
42    // The default commitment policy if you were to build the client like in
43    // the `keyring/aws_kms_keyring_example.rs` is RequireEncryptRequireDecrypt.
44    // We recommend that AWS Encryption SDK users use the default commitment policy
45    // (RequireEncryptRequireDecrypt) whenever possible.
46    let esdk_config = AwsEncryptionSdkConfig::builder()
47        .commitment_policy(ForbidEncryptAllowDecrypt)
48        .build()?;
49    let esdk_client = esdk_client::Client::from_conf(esdk_config)?;
50
51    // 2. Create a KMS client.
52    let sdk_config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
53    let kms_client = aws_sdk_kms::Client::new(&sdk_config);
54
55    // 3. Create encryption context.
56    // Remember that your encryption context is NOT SECRET.
57    // For more information, see
58    // https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#encryption-context
59    let encryption_context = HashMap::from([
60        ("encryption".to_string(), "context".to_string()),
61        ("is not".to_string(), "secret".to_string()),
62        ("but adds".to_string(), "useful metadata".to_string()),
63        (
64            "that can help you".to_string(),
65            "be confident that".to_string(),
66        ),
67        (
68            "the data you are handling".to_string(),
69            "is what you think it is".to_string(),
70        ),
71    ]);
72
73    // 4. Create a KMS keyring
74    let mpl_config = MaterialProvidersConfig::builder().build()?;
75    let mpl = mpl_client::Client::from_conf(mpl_config)?;
76
77    let kms_keyring = mpl
78        .create_aws_kms_keyring()
79        .kms_key_id(kms_key_id)
80        .kms_client(kms_client)
81        .send()
82        .await?;
83
84    // 5. Encrypt the data with the encryption_context. Make sure you use a non-committing algorithm
85    // with the commitment policy ForbidEncryptAllowDecrypt. Otherwise esdk_client.encrypt() will throw
86    // Error: AwsCryptographicMaterialProvidersError
87    //   {
88    //     error: InvalidAlgorithmSuiteInfoOnEncrypt
89    //     {
90    //       message: "Configuration conflict. Commitment policy requires only non-committing algorithm suites"
91    //     }
92    //   }
93    // By default for ForbidEncryptAllowDecrypt, the algorithm used is
94    // AlgAes256GcmIv12Tag16HkdfSha384EcdsaP384 which is a non-committing algorithm.
95    let plaintext = example_data.as_bytes();
96
97    let encryption_response = esdk_client
98        .encrypt()
99        .plaintext(plaintext)
100        .keyring(kms_keyring.clone())
101        .encryption_context(encryption_context.clone())
102        .send()
103        .await?;
104
105    let ciphertext = encryption_response
106        .ciphertext
107        .expect("Unable to unwrap ciphertext from encryption response");
108
109    // 6. Demonstrate that the ciphertext and plaintext are different.
110    // (This is an example for demonstration; you do not need to do this in your own code.)
111    assert_ne!(
112        ciphertext,
113        aws_smithy_types::Blob::new(plaintext),
114        "Ciphertext and plaintext data are the same. Invalid encryption"
115    );
116
117    // 7. Decrypt your encrypted data using the same keyring you used on encrypt.
118    let decryption_response = esdk_client
119        .decrypt()
120        .ciphertext(ciphertext)
121        .keyring(kms_keyring)
122        // Provide the encryption context that was supplied to the encrypt method
123        .encryption_context(encryption_context)
124        .send()
125        .await?;
126
127    let decrypted_plaintext = decryption_response
128        .plaintext
129        .expect("Unable to unwrap plaintext from decryption response");
130
131    // 8. Demonstrate that the decrypted plaintext is identical to the original plaintext.
132    // (This is an example for demonstration; you do not need to do this in your own code.)
133    assert_eq!(
134        decrypted_plaintext,
135        aws_smithy_types::Blob::new(plaintext),
136        "Decrypted plaintext should be identical to the original plaintext. Invalid decryption"
137    );
138
139    println!("Set Commitment Policy Example Completed Successfully");
140
141    Ok(())
142}

Trait Implementations§

Source§

impl Clone for MaterialProvidersConfig

Source§

fn clone(&self) -> MaterialProvidersConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MaterialProvidersConfig

Source§

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

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

impl PartialEq for MaterialProvidersConfig

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 StructuralPartialEq for MaterialProvidersConfig

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> AnyRef for T
where T: 'static,

Source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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, 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> Upcast<T> for T
where T: ?Sized,

Source§

fn upcast(&self) -> Ptr<T>

Source§

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

Source§

fn upcast(&self) -> Object<T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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