chore: 使用 Arc 代替 Rc

This commit is contained in:
amtoaer
2024-03-23 00:09:31 +08:00
parent 1e16c40adc
commit 705877d497
3 changed files with 11 additions and 10 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
use std::rc::Rc; use std::sync::Arc;
use crate::Result; use crate::Result;
@@ -44,7 +44,7 @@ pub struct FilterOption {
pub video_min_quality: VideoQuality, pub video_min_quality: VideoQuality,
pub audio_max_quality: AudioQuality, pub audio_max_quality: AudioQuality,
pub audio_min_quality: AudioQuality, pub audio_min_quality: AudioQuality,
pub codecs: Rc<Vec<VideoCodecs>>, pub codecs: Arc<Vec<VideoCodecs>>,
pub no_dolby_video: bool, pub no_dolby_video: bool,
pub no_dolby_audio: bool, pub no_dolby_audio: bool,
pub no_hdr: bool, pub no_hdr: bool,
+6 -5
View File
@@ -1,4 +1,4 @@
use std::rc::Rc; use std::sync::Arc;
use async_stream::stream; use async_stream::stream;
use futures_core::stream::Stream; use futures_core::stream::Stream;
@@ -7,15 +7,15 @@ use serde_json::Value;
use crate::bilibili::BiliClient; use crate::bilibili::BiliClient;
use crate::Result; use crate::Result;
pub struct FavoriteList { pub struct FavoriteList {
client: Rc<BiliClient>, client: Arc<BiliClient>,
fid: String, fid: String,
} }
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug, serde::Deserialize)] #[derive(Debug, serde::Deserialize)]
pub struct FavoriteListInfo { pub struct FavoriteListInfo {
id: u64, pub id: u64,
title: String, pub title: String,
} }
#[derive(Debug, serde::Deserialize)] #[derive(Debug, serde::Deserialize)]
@@ -29,6 +29,7 @@ pub struct VideoInfo {
pub upper: Upper, pub upper: Upper,
pub ctime: u64, pub ctime: u64,
pub fav_time: u64, pub fav_time: u64,
pub pubtime: u64,
} }
#[derive(Debug, serde::Deserialize)] #[derive(Debug, serde::Deserialize)]
@@ -37,7 +38,7 @@ pub struct Upper {
pub name: String, pub name: String,
} }
impl FavoriteList { impl FavoriteList {
pub fn new(client: Rc<BiliClient>, fid: String) -> Self { pub fn new(client: Arc<BiliClient>, fid: String) -> Self {
Self { client, fid } Self { client, fid }
} }
+3 -3
View File
@@ -1,4 +1,4 @@
use std::rc::Rc; use std::sync::Arc;
use reqwest::Method; use reqwest::Method;
@@ -17,7 +17,7 @@ static DATA: &[char] = &[
]; ];
pub struct Video { pub struct Video {
client: Rc<BiliClient>, client: Arc<BiliClient>,
pub aid: String, pub aid: String,
pub bvid: String, pub bvid: String,
} }
@@ -39,7 +39,7 @@ pub struct Page {
} }
impl Video { impl Video {
pub fn new(client: Rc<BiliClient>, bvid: String) -> Self { pub fn new(client: Arc<BiliClient>, bvid: String) -> Self {
let aid = bvid_to_aid(&bvid).to_string(); let aid = bvid_to_aid(&bvid).to_string();
Self { client, aid, bvid } Self { client, aid, bvid }
} }