Struct vtubestudio::data::ResponseEnvelope
source · pub struct ResponseEnvelope {
pub api_name: Cow<'static, str>,
pub api_version: Cow<'static, str>,
pub timestamp: i64,
pub request_id: RequestId,
pub data: Result<ResponseData, ApiError>,
}
Expand description
A VTube Studio API response.
Fields§
§api_name: Cow<'static, str>
API name, typically "VTubeStudioPublicAPI"
.
api_version: Cow<'static, str>
API version, typically "1.0"
.
timestamp: i64
Unix timestamp (in milliseconds) of the response.
request_id: RequestId
The original request ID.
data: Result<ResponseData, ApiError>
Response data, which could be an ApiError
.
Implementations§
source§impl ResponseEnvelope
impl ResponseEnvelope
sourcepub fn new<Resp>(data: &Resp) -> Result<Self, Error>
pub fn new<Resp>(data: &Resp) -> Result<Self, Error>
Creates a new response with the underlying typed data.
sourcepub fn set_data<Resp>(&mut self, data: &Resp) -> Result<(), Error>
pub fn set_data<Resp>(&mut self, data: &Resp) -> Result<(), Error>
Sets the data
field of a response.
sourcepub fn message_type(&self) -> &EnumString<ResponseType>
pub fn message_type(&self) -> &EnumString<ResponseType>
The message type of this response.
sourcepub fn parse_event(self) -> Result<Event, Error>
pub fn parse_event(self) -> Result<Event, Error>
Attempts to parse the response as an Event
.
This can return an error if the message type is an ApiError
or has an unexpected JSON
structure. If the message type is not a known Event
variant, it will be returned as
Event::Unknown
instead of an error.
sourcepub fn is_api_error(&self) -> bool
pub fn is_api_error(&self) -> bool
Returns true
if the message type is APIError
.
sourcepub fn is_unauthenticated_error(&self) -> bool
pub fn is_unauthenticated_error(&self) -> bool
Returns true
if the message is an APIError
with
ErrorId::REQUEST_REQUIRES_AUTHENTICATION
.
Trait Implementations§
source§impl Clone for ResponseEnvelope
impl Clone for ResponseEnvelope
source§fn clone(&self) -> ResponseEnvelope
fn clone(&self) -> ResponseEnvelope
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ResponseEnvelope
impl Debug for ResponseEnvelope
source§impl Default for ResponseEnvelope
impl Default for ResponseEnvelope
source§impl<'de> Deserialize<'de> for ResponseEnvelope
impl<'de> Deserialize<'de> for ResponseEnvelope
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Policy<RequestEnvelope, ResponseEnvelope, Error> for RetryPolicy
impl Policy<RequestEnvelope, ResponseEnvelope, Error> for RetryPolicy
§type Future = Ready<RetryPolicy>
type Future = Ready<RetryPolicy>
The
Future
type returned by Policy::retry
.source§fn retry(
&self,
req: &RequestEnvelope,
result: Result<&ResponseEnvelope, &Error>,
) -> Option<Self::Future>
fn retry( &self, req: &RequestEnvelope, result: Result<&ResponseEnvelope, &Error>, ) -> Option<Self::Future>
Check the policy if a certain request should be retried. Read more
source§fn clone_request(&self, req: &RequestEnvelope) -> Option<RequestEnvelope>
fn clone_request(&self, req: &RequestEnvelope) -> Option<RequestEnvelope>
Tries to clone a request before being passed to the inner service. Read more
Auto Trait Implementations§
impl Freeze for ResponseEnvelope
impl RefUnwindSafe for ResponseEnvelope
impl Send for ResponseEnvelope
impl Sync for ResponseEnvelope
impl Unpin for ResponseEnvelope
impl UnwindSafe for ResponseEnvelope
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more