Skip to content

Commit 3161a4e

Browse files
committed
Add post_type_supports helper to check feature support
Add a `supports` method to `PostTypeSupportsMap` for Rust usage and a `post_type_supports` free function for FFI clients to check if a post type supports a specific feature by key presence.
1 parent d30f9c7 commit 3161a4e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

wp_api/src/post_types.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ pub struct PostTypeSupportsMap {
101101
pub map: HashMap<PostTypeSupports, Arc<PostTypeSupportsValue>>,
102102
}
103103

104+
impl PostTypeSupportsMap {
105+
/// Check if the post type supports a specific feature by checking if the key is present.
106+
pub fn supports(&self, feature: &PostTypeSupports) -> bool {
107+
self.map.contains_key(feature)
108+
}
109+
}
110+
111+
/// Check if a post type supports a specific feature by checking if the key is present.
112+
#[uniffi::export]
113+
fn post_type_supports(supports_map: &PostTypeSupportsMap, feature: PostTypeSupports) -> bool {
114+
supports_map.supports(&feature)
115+
}
116+
104117
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, uniffi::Object)]
105118
#[serde(transparent)]
106119
pub struct PostTypeSupportsValue {

0 commit comments

Comments
 (0)