diff options
| author | Matthew Collins <[email protected]> | 2021-03-01 20:44:52 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-03-01 20:44:52 +0000 |
| commit | 7fced0370288dade134d7972f2269aff6a1984ba (patch) | |
| tree | 2c5d54d3ea74dc47550b60aebd5205898e938b8c | |
| parent | Merge pull request #31 from WilliamVenner/master (diff) | |
| parent | u32 cast -> _ cast (diff) | |
| download | archived-steamworks-rs-7fced0370288dade134d7972f2269aff6a1984ba.tar.xz archived-steamworks-rs-7fced0370288dade134d7972f2269aff6a1984ba.zip | |
Merge pull request #32 from WilliamVenner/master
Add QueryResults::preview_url to get preview URL of a UGC published file from QueryResults
| -rw-r--r-- | src/ugc.rs | 23 |
1 files changed, 21 insertions, 2 deletions
@@ -368,7 +368,7 @@ impl <Manager> UGC<Manager> { let mut timestamp = 0u32; if sys::SteamAPI_ISteamUGC_GetItemInstallInfo(self.ugc, item.0, &mut size_on_disk, folder.as_mut_ptr(), folder.len() as _, &mut timestamp) { Some(InstallInfo { - folder: CStr::from_ptr(folder.as_ptr() as *const _ as *const _) + folder: CStr::from_ptr(folder.as_ptr() as *const _) .to_string_lossy() .into_owned(), size_on_disk, @@ -699,7 +699,7 @@ impl <Manager> UserListQuery<Manager> { self.fetch(move |res| cb(res.map(|qr| qr.total_results()))) } - /// Runs the query, only fetchind the IDs. + /// Runs the query, only fetching the IDs. pub fn fetch_ids<F>(self, cb: F) where F: Fn(Result<Vec<PublishedFileId>, SteamError>) + 'static + Send { @@ -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<String> { + 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 _) + }; + + 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. |