#[non_exhaustive]pub struct Rating {
pub rating_count: i32,
pub average_rating: f32,
pub rating_histogram: Vec<i32>,
/* private fields */
}Expand description
The rating of a Product.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.rating_count: i32The total number of ratings. This value is independent of the value of rating_histogram.
This value must be nonnegative. Otherwise, an INVALID_ARGUMENT error is returned.
average_rating: f32The average rating of the Product.
The rating is scaled at 1-5. Otherwise, an INVALID_ARGUMENT error is returned.
rating_histogram: Vec<i32>List of rating counts per rating value (index = rating - 1). The list is empty if there is no rating. If the list is non-empty, its size is always 5. Otherwise, an INVALID_ARGUMENT error is returned.
For example, [41, 14, 13, 47, 303]. It means that the Product got 41 ratings with 1 star, 14 ratings with 2 star, and so on.
Implementations§
Source§impl Rating
impl Rating
Sourcepub fn set_rating_count<T: Into<i32>>(self, v: T) -> Self
pub fn set_rating_count<T: Into<i32>>(self, v: T) -> Self
Sourcepub fn set_average_rating<T: Into<f32>>(self, v: T) -> Self
pub fn set_average_rating<T: Into<f32>>(self, v: T) -> Self
Sourcepub fn set_rating_histogram<T, V>(self, v: T) -> Self
pub fn set_rating_histogram<T, V>(self, v: T) -> Self
Sets the value of rating_histogram.
§Example
ⓘ
let x = Rating::new().set_rating_histogram([1, 2, 3]);Trait Implementations§
impl StructuralPartialEq for Rating
Auto Trait Implementations§
impl Freeze for Rating
impl RefUnwindSafe for Rating
impl Send for Rating
impl Sync for Rating
impl Unpin for Rating
impl UnsafeUnpin for Rating
impl UnwindSafe for Rating
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