docs: more model documentation

This commit is contained in:
ThetaDev 2022-09-27 16:25:47 +02:00
parent 305c3ee70e
commit 49f3aa3577
7 changed files with 48 additions and 23 deletions

View file

@ -1,8 +1,12 @@
// This file is automatically generated. DO NOT EDIT.
//! Languages and countries
use std::{fmt::Display, str::FromStr};
use serde::{Deserialize, Serialize};
/// Available languages
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[serde(rename_all = "lowercase")]
pub enum Language {
@ -184,6 +188,7 @@ pub enum Language {
Zu,
}
/// Available countries
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[serde(rename_all = "UPPERCASE")]
pub enum Country {
@ -407,6 +412,7 @@ pub enum Country {
Zw,
}
/// Array of all available languages
pub const LANGUAGES: [Language; 83] = [
Language::Af,
Language::Am,
@ -493,6 +499,7 @@ pub const LANGUAGES: [Language; 83] = [
Language::Zu,
];
/// Array of all available countries
pub const COUNTRIES: [Country; 109] = [
Country::Ae,
Country::Ar,
@ -606,6 +613,9 @@ pub const COUNTRIES: [Country; 109] = [
];
impl Language {
/// Get the native name of the language
///
/// Examples: "English (US)", "Deutsch", "中文 (简体)"
pub fn name(&self) -> &str {
match self {
Language::Af => "Afrikaans",
@ -696,6 +706,9 @@ impl Language {
}
impl Country {
/// Get the English name of the country
///
/// Examples: "United States", "Germany"
pub fn name(&self) -> &str {
match self {
Country::Ae => "United Arab Emirates",

View file

@ -465,9 +465,9 @@ pub struct VideoDetails {
///
/// Information about the license:
///
/// https://www.youtube.com/t/creative_commons
/// <https://www.youtube.com/t/creative_commons>
///
/// https://creativecommons.org/licenses/by/3.0/
/// <https://creativecommons.org/licenses/by/3.0/>
pub is_ccommons: bool,
/// Chapters of the video
pub chapters: Vec<Chapter>,

View file

@ -1,3 +1,5 @@
//! Data model for texts with links
use serde::{Deserialize, Serialize};
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
@ -41,6 +43,7 @@ pub trait ToPlaintext {
/// Trait for converting rich text to html.
#[cfg(feature = "html")]
#[cfg_attr(docsrs, doc(cfg(feature = "html")))]
pub trait ToHtml {
/// Convert rich text to html.
fn to_html(&self) -> String {
@ -93,6 +96,7 @@ impl ToPlaintext for TextComponent {
}
#[cfg(feature = "html")]
#[cfg_attr(docsrs, doc(cfg(feature = "html")))]
impl ToHtml for TextComponent {
fn to_html_yt_host(&self, yt_host: &str) -> String {
match self {
@ -127,6 +131,7 @@ impl ToPlaintext for RichText {
}
#[cfg(feature = "html")]
#[cfg_attr(docsrs, doc(cfg(feature = "html")))]
impl ToHtml for RichText {
fn to_html_yt_host(&self, yt_host: &str) -> String {
self.0.iter().map(|c| c.to_html_yt_host(yt_host)).collect()

View file

@ -1,3 +1,5 @@
//! Filters for selecting audio/video streams
use std::collections::HashSet;
use super::{