1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
12 /// Wrapper over `VAStatus`, calling check() returns a Error if the status is not VA_STATUS_SUCCESS.
13 #[must_use = "VAStatus might not be VA_STATUS_SUCCESS."]
14 pub(crate) struct Status(pub bindings::VAStatus);
17 /// Returns `Ok(())` if this status is successful, and an error otherwise.
18 pub(crate) fn check(&self) -> Result<()> {
19 if self.0 == bindings::constants::VA_STATUS_SUCCESS as i32 {
22 // Safe because `vaErrorStr` will return a pointer to a statically allocated, null
23 // terminated C string. The pointer is guaranteed to never be null.
24 let err_str = unsafe { CStr::from_ptr(bindings::vaErrorStr(self.0)) }
27 Err(anyhow!("VA-API error: {}: {}", self.0, err_str))