aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Venner <[email protected]>2021-04-24 00:07:17 +0100
committerWilliam Venner <[email protected]>2021-04-24 00:07:17 +0100
commita33ebe97165c4e19cd2d553350afd2487b6d8ec4 (patch)
treecad873a4d0d826ef52a857c16a3fe53a40e3885c /src
parentAdd safe wrapper for sys::SteamParamStringArray_t (diff)
downloadsteamworks-rs-a33ebe97165c4e19cd2d553350afd2487b6d8ec4.tar.xz
steamworks-rs-a33ebe97165c4e19cd2d553350afd2487b6d8ec4.zip
Add more UGC bindings
Diffstat (limited to 'src')
-rw-r--r--src/ugc.rs79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/ugc.rs b/src/ugc.rs
index e257cdc..2de046a 100644
--- a/src/ugc.rs
+++ b/src/ugc.rs
@@ -543,6 +543,26 @@ impl <Manager> UGC<Manager> {
handle: Some(res),
})
}
+
+ /// **DELETES** the item from the Steam Workshop.
+ pub fn delete_item<F>(&self, published_file_id: PublishedFileId, cb: F)
+ where F: FnOnce(Result<(), SteamError>) + 'static + Send
+ {
+ unsafe {
+ let api_call = sys::SteamAPI_ISteamUGC_DeleteItem(self.ugc, published_file_id.0);
+ register_call_result::<sys::DownloadItemResult_t, _, _>(
+ &self.inner, api_call, CALLBACK_REMOTE_STORAGE_BASE_ID + 17,
+ move |v, io_error| {
+ cb(if io_error {
+ Err(SteamError::IOFailure)
+ } else if v.m_eResult != sys::EResult::k_EResultNone && v.m_eResult != sys::EResult::k_EResultOK {
+ Err(v.m_eResult.into())
+ } else {
+ Ok(())
+ })
+ });
+ }
+ }
}
/// A handle to update a published item
@@ -592,6 +612,14 @@ impl <Manager> UpdateHandle<Manager> {
self
}
+ pub fn tags<S: AsRef<str>>(self, tags: Vec<S>) -> Self {
+ unsafe {
+ let mut tags = SteamParamStringArray::new(&tags);
+ assert!(sys::SteamAPI_ISteamUGC_SetItemTags(self.ugc, self.handle, &tags.as_raw()));
+ }
+ self
+ }
+
pub fn submit<F>(self, change_note: Option<&str>, cb: F) -> UpdateWatchHandle<Manager>
where F: FnOnce(Result<(PublishedFileId, bool), SteamError>) + 'static + Send
{
@@ -1237,6 +1265,57 @@ impl<'a> QueryResults<'a> {
None
}
}
+
+ /// Returns the number of key value tags associated with the item at the specified index.
+ pub fn key_value_tags(&self, index: u32) -> u32 {
+ unsafe { sys::SteamAPI_ISteamUGC_GetQueryUGCNumKeyValueTags(self.ugc, self.handle, index) }
+ }
+
+ /// Gets the key value pair of a specified key value tag associated with the item at the specified index.
+ pub fn get_key_value_tag(&self, index: u32, kv_tag_index: u32) -> Option<(String, String)> {
+ let mut key = [0 as c_char; 256];
+ let mut value = [0 as c_char; 256];
+
+ let ok = unsafe {
+ sys::SteamAPI_ISteamUGC_GetQueryUGCKeyValueTag(self.ugc, self.handle, index, kv_tag_index, key.as_mut_ptr(), 256, value.as_mut_ptr(), 256)
+ };
+
+ if ok {
+ Some(unsafe {(
+ CStr::from_ptr(key.as_ptr() as *const _)
+ .to_string_lossy()
+ .into_owned(),
+
+ CStr::from_ptr(value.as_ptr() as *const _)
+ .to_string_lossy()
+ .into_owned()
+ )})
+ } else {
+ None
+ }
+ }
+
+ /// Gets the developer-set metadata associated with the item at the specified index.
+ ///
+ /// This is returned as a vector of raw bytes.
+ pub fn get_metadata(&self, index: u32) -> Option<Vec<u8>> {
+ let mut metadata = [0 as c_char; sys::k_cchDeveloperMetadataMax as usize];
+
+ let ok = unsafe {
+ sys::SteamAPI_ISteamUGC_GetQueryUGCMetadata(self.ugc, self.handle, index, metadata.as_mut_ptr(), sys::k_cchDeveloperMetadataMax)
+ };
+
+ if ok {
+ let metadata = unsafe { CStr::from_ptr(metadata.as_ptr() as *const _).to_bytes() };
+ if metadata.is_empty() {
+ None
+ } else {
+ Some(metadata.to_vec())
+ }
+ } else {
+ None
+ }
+ }
}
/// Query result