Skip to content

Commit

Permalink
docs(bindings): example for Policy::from_version (#4731)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmayclin authored Sep 18, 2024
1 parent 1c948da commit e896037
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bindings/rust/s2n-tls/src/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,29 @@ impl Policy {
}
}

/// Construct a numbered security policy.
///
/// Numbered security policies are stable and will not change, in comparison
/// to default security policies: [DEFAULT] and [DEFAULT_TLS13].
///
/// See the s2n-tls usage guide for details on available policies:
/// <https://aws.github.io/s2n-tls/usage-guide/ch06-security-policies.html>
/// ```
/// use s2n_tls::{config, security};
///
/// let mut config = config::Builder::new();
///
/// // "20240501" is a numbered security policy. More information can be found
/// // in the linked s2n-tls usage guide.
/// let security_policy = match security::Policy::from_version("20240501") {
/// Ok(policy) => policy,
/// Err(e) => {
/// eprintln!("unable to construct the policy: {}", e);
/// return;
/// }
/// };
/// config.set_security_policy(&security_policy);
/// ```
pub fn from_version(version: &str) -> Result<Policy, Error> {
let cstr = CString::new(version).map_err(|_| Error::INVALID_INPUT)?;
let context = Context::Owned(cstr);
Expand Down

0 comments on commit e896037

Please sign in to comment.