From 8acfc7caad08be2c7d2ea57cafde402ac28ebbcf Mon Sep 17 00:00:00 2001 From: William Venner Date: Sun, 28 Feb 2021 19:39:30 +0000 Subject: Add QueryResults::preview_url to get preview URL of UGC published file --- src/ugc.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ugc.rs b/src/ugc.rs index 82cc0fe..49e5922 100644 --- a/src/ugc.rs +++ b/src/ugc.rs @@ -745,6 +745,25 @@ impl<'a> QueryResults<'a> { self.num_results_returned } + /// Gets the preview URL of the published file at the specified index. + pub fn preview_url(&self, index: u32) -> Option { + let mut url = [0 as libc::c_char; 4096]; + + let ok = unsafe { + sys::SteamAPI_ISteamUGC_GetQueryUGCPreviewURL(self.ugc, self.handle, index, url.as_mut_ptr(), url.len() as u32) + }; + + if ok { + Some(unsafe { + CStr::from_ptr(url.as_ptr() as *const _) + .to_string_lossy() + .into_owned() + }) + } else { + None + } + } + /// Gets a result. /// /// Returns None if index was out of bounds. -- cgit v1.2.3