summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/src/policy.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp-ffi/src/policy.rs')
-rw-r--r--openpgp-ffi/src/policy.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/openpgp-ffi/src/policy.rs b/openpgp-ffi/src/policy.rs
new file mode 100644
index 00000000..2c00ae52
--- /dev/null
+++ b/openpgp-ffi/src/policy.rs
@@ -0,0 +1,36 @@
+//! Policy objects.
+//!
+//! This module allows the caller to specify low-level policy like
+//! what algorithms are allowed.
+//!
+//! Wraps the policy object functions, see
+//! [`sequoia-openpgp::policy`].
+//!
+//! [`sequoia-openpgp::policy`]: ../../sequoia_openpgp/policy/index.html
+
+extern crate sequoia_openpgp as openpgp;
+
+use crate::MoveIntoRaw;
+
+use self::openpgp::policy;
+
+/// A policy object.
+#[crate::ffi_wrapper_type(
+ prefix = "pgp_",
+ derive = "Clone, Debug")]
+pub struct Policy(Box<policy::Policy>);
+
+/// A StandardPolicy object.
+#[crate::ffi_wrapper_type(
+ prefix = "pgp_",
+ derive = "Clone, Debug")]
+pub struct StandardPolicy(policy::StandardPolicy);
+
+/// Returns a new standard policy.
+#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
+pub extern "C" fn pgp_standard_policy()
+ -> *mut Policy
+{
+ let p : Box<policy::Policy> = Box::new(policy::StandardPolicy::new());
+ p.move_into_raw()
+}