### Start TikTokLiveWebsocketClient Source: https://docs.rs/tiktoklive/latest/tiktoklive/core/live_client_websocket/struct.TikTokLiveWebsocketClient.html Asynchronously starts the WebSocket client. This method requires the initial connection response data and a shared reference to the TikTokLiveClient. ```rust pub async fn start( &self, response: LiveConnectionDataResponse, client: Arc, ) -> Result<(), LibError> ``` -------------------------------- ### TikTokLiveBuilder::new Source: https://docs.rs/tiktoklive/latest/tiktoklive/core/live_client_builder/struct.TikTokLiveBuilder.html Creates a new instance of the TikTokLiveBuilder. This is the starting point for building a TikTok Live client. ```APIDOC ## TikTokLiveBuilder::new ### Description Creates a new TikTokLiveBuilder instance, which is used to configure and build a TikTokLiveClient. ### Method ```rust pub fn new(user_name: &str) -> Self ``` ### Parameters #### Path Parameters - **user_name** (str) - Required - The name of the TikTok user for whom the live client will be built. This can typically be found in the live stream URL. ``` -------------------------------- ### Create New WebcastRoomMessage Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastRoomMessage.html Instantiates a new, empty WebcastRoomMessage object. This is a common way to start building a message. ```rust fn new() -> WebcastRoomMessage ``` -------------------------------- ### TikTokLive Client Entry Point Source: https://docs.rs/tiktoklive/latest/tiktoklive/struct.TikTokLive.html This section describes the primary entry point for creating a new instance of the TikTokLive client. It shows how to use the `new_client` function to get a builder and then connect to the live stream. ```APIDOC ## Entry point of library used to create new instance of TikTokLive client This function serves as the entry point for initializing a TikTokLive client. It returns a builder that can be used to configure and establish a connection. ### Usage Example ```rust use tiktoklive::TikTokLive; let client = TikTokLive::new_client("some-user"); client.connect().await ``` ### Function Signature `pub fn new_client(user_name: &str) -> TikTokLiveBuilder` ### Parameters - **user_name** (`&str`): The username for which to create the TikTokLive client. ``` -------------------------------- ### LinkmicInfo Default Implementations Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/linker_reply_content/struct.LinkmicInfo.html Provides default values for LinkmicInfo. Use `Default for LinkmicInfo` to get a new, empty instance, or `Default for &LinkmicInfo` to get a reference to a static default instance. ```rust fn default() -> LinkmicInfo ``` ```rust fn default() -> &'a LinkmicInfo ``` -------------------------------- ### Initialize and Connect TikTokLive Client Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/core/live_client.rs.html Initializes the TikTokLiveClient and establishes a connection. It first checks if the client is already connected, then fetches user and room information via HTTP requests. If the host is online, it proceeds to fetch connection data and starts the WebSocket client. ```rust pub async fn connect(mut self) -> Result<(), LibError> { if *(self.room_info.connection_state.lock().unwrap()) != DISCONNECTED { warn!("Client already connected!"); return Ok(()); } self.set_connection_state(CONNECTING); info!("Getting live user information's"); let response = self .http_client .fetch_live_user_data(LiveUserDataRequest { user_name: self.settings.host_name.clone(), }) .await?; info!("Getting live room information's"); let room_id = response.room_id; let response = self .http_client .fetch_live_data(LiveDataRequest { room_id: room_id.clone(), }) .await?; self.room_info.client_data = response.json; if response.live_status != HostOnline { error!( "Live stream for host is not online!, current status {:?}", response.live_status ); self.set_connection_state(DISCONNECTED); return Err(LibError::HostNotOnline); } info!("Getting live connections information's"); let response = self .http_client .fetch_live_connection_data(LiveConnectionDataRequest { room_id: room_id.clone(), }) .await; let client_arc = Arc::new(self); let ws = TikTokLiveWebsocketClient { message_mapper: TikTokLiveMessageMapper {}, running: Arc::new(AtomicBool::new(false)), }; let _ = ws.start(response?, client_arc).await; Ok(()) } ``` -------------------------------- ### Get Room Information Source: https://docs.rs/tiktoklive/latest/tiktoklive/core/live_client/struct.TikTokLiveClient.html Retrieves the room information as a String reference. ```rust pub fn get_room_info(&self) -> &String ``` -------------------------------- ### Initialize TikTokLiveBuilder Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/core/live_client_builder.rs.html Creates a new TikTokLiveBuilder instance for a specific TikTok user. This is the starting point for building a TikTokLiveClient. ```rust use crate::core::live_client::TikTokLiveClient; use crate::core::live_client_events::{TikTokEventHandler, TikTokLiveEventObserver}; use crate::core::live_client_http::TikTokLiveHttpClient; use crate::core::live_client_mapper::TikTokLiveMessageMapper; use crate::core::live_client_websocket::TikTokLiveWebsocketClient; use crate::data::create_default_settings; use crate::data::live_common::{TikTokLiveInfo, TikTokLiveSettings}; use crate::http::http_request_builder::HttpRequestFactory; pub struct TikTokLiveBuilder { settings: TikTokLiveSettings, pub(crate) event_observer: TikTokLiveEventObserver, } impl TikTokLiveBuilder { /// /// # Create new tiktok live builder /// /// ### user_name - name of tiktok user that can be found in the live link /// pub fn new(user_name: &str) -> Self { Self { settings: create_default_settings(user_name), event_observer: TikTokLiveEventObserver::new(), } } /// /// # Configure live connection settings /// /// pub fn configure(&mut self, on_configure: F) -> &mut Self where F: FnOnce(&mut TikTokLiveSettings), { on_configure(&mut self.settings); self } /// /// # Invoked every time new event is coming from tiktok /// /// ## client - instance of TikTokLiveClient /// ## event - invoked event /// ``` /// pub fn on_event(&mut self, on_event: TikTokEventHandler) -> &mut Self { self.event_observer.subscribe(on_event); self } /// /// Returns new instance of TikTokLiveClient /// pub fn build(&self) -> TikTokLiveClient { let settings = &self.settings; let observer = self.event_observer.clone(); let mapper = TikTokLiveMessageMapper {}; let websocket_client = TikTokLiveWebsocketClient::new(mapper); let http_factory = HttpRequestFactory { settings: settings.clone(), }; let http_client = TikTokLiveHttpClient { settings: settings.clone(), factory: http_factory, }; TikTokLiveClient::new( settings.clone(), http_client, observer, websocket_client, TikTokLiveInfo::default(), ) } } ``` -------------------------------- ### New GiftPanelBanner Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/gift_struct/struct.GiftPanelBanner.html Creates a new, empty instance of the GiftPanelBanner struct. This is often used as a starting point before populating fields. ```rust pub fn new() -> GiftPanelBanner ``` -------------------------------- ### HttpRequestBuilder: Build GET Request Source: https://docs.rs/tiktoklive/latest/tiktoklive/http/http_request_builder/struct.HttpRequestBuilder.html Builds a GET request object from the HttpRequestBuilder. This is a specific type of request that can be further configured or sent. ```rust pub fn build_get_request(&mut self) -> RequestBuilder ``` -------------------------------- ### Fetch Live Connection Data Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/core/live_client_http.rs.html Prepares for a WebSocket connection by signing a URL and obtaining necessary credentials. This involves multiple steps including URL signing and parsing protobuf messages. ```rust pub async fn fetch_live_connection_data( &self, request: LiveConnectionDataRequest, ) -> Result { // Preparing URL to sign let url_to_sign = self .factory .request() .with_url(format!("{}{}", TIKTOK_URL_WEBCAST, "im/fetch").as_str()) .with_param("room_id", request.room_id.as_str()) .as_url(); // Signing URL let option = self .factory .request() .with_url(TIKTOK_SIGN_API) .with_param("client", "ttlive-rust") .with_param("uuc", "1") .with_param("url", url_to_sign.as_str()) .with_param("apiKey", self.settings.sign_api_key.as_str()) .as_json() .await; let json = option.ok_or(LibError::UrlSigningFailed)?; let sign_server_response = map_sign_server_response(json); // Getting credentials for connection to websocket let response = self .factory .request() .with_reset() .with_time_out(self.settings.http_data.time_out) .with_url(sign_server_response.signed_url.as_str()) .build_get_request() .send() .await .map_err(|_| LibError::HttpRequestFailed)?; let optional_header = response.headers().get("set-cookie"); let header_value = optional_header .ok_or(LibError::HeaderNotReceived)? .to_str() .map_err(|_| LibError::HeaderNotReceived)? .to_string(); let protocol_buffer_message = response .bytes() .await .map_err(|_| LibError::BytesParseError)?; let webcast_response = WebcastResponse::parse_from_bytes(protocol_buffer_message.as_ref()) .map_err(|_| LibError::BytesParseError)?; // Preparing websocket URL let web_socket_url = self .factory .request() .with_url(webcast_response.pushServer.as_str()) .with_param("room_id", request.room_id.as_str()) .with_param("cursor", webcast_response.cursor.as_str()) .with_param("resp_content_type", "protobuf") .with_param("internal_ext", webcast_response.internalExt.as_str()) .with_params(&webcast_response.routeParamsMap) .as_url(); let url = url::Url::parse(web_socket_url.as_str()).map_err(|_| LibError::InvalidHost)?; Ok(LiveConnectionDataResponse { ``` -------------------------------- ### New InviteBizContent Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/multi_live_content/struct.InviteBizContent.html Provides a function to create a new, empty instance of InviteBizContent. This is a common method for initializing message structures. ```rust pub fn new() -> InviteBizContent ``` -------------------------------- ### GetTypeId Implementation Source: https://docs.rs/tiktoklive/latest/tiktoklive/core/live_client/struct.TikTokLiveClient.html Gets the TypeId of the current type. This is part of the Any trait implementation. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### LinkmicUserSettingInfo New Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.LinkmicUserSettingInfo.html Creates a new, empty instance of LinkmicUserSettingInfo. This is the constructor for the struct. ```rust fn new() -> LinkmicUserSettingInfo ``` -------------------------------- ### Create New WebcastLinkMicFanTicketMethod Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastLinkMicFanTicketMethod.html Provides a constructor function to create a new, empty instance of the WebcastLinkMicFanTicketMethod struct. ```rust pub fn new() -> WebcastLinkMicFanTicketMethod ``` -------------------------------- ### Get Default Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_barrage_message/struct.BarrageTypeUserGradeParam.html Returns a static reference to the default immutable BarrageTypeUserGradeParam message. ```rust fn default_instance() -> &'static BarrageTypeUserGradeParam ``` -------------------------------- ### Create New TikTokLive Client Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/struct.TikTokLive.html Entry point for creating a new instance of the TikTokLive client. Requires the target user's name and an asynchronous connection attempt. ```rust use tiktoklive::TikTokLive; let client = TikTokLive::new_client("some-user"); client.connect().await ``` -------------------------------- ### Get Cached Size Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastLinkMicArmies.html Retrieves the size of the message that was previously computed and cached by `compute_size`. ```rust fn cached_size(&self) -> u32; ``` -------------------------------- ### PartialEq Implementation for FollowInfo Source: https://docs.rs/tiktoklive/latest/tiktoklive/data/live_common/struct.FollowInfo.html Allows for equality comparison between FollowInfo instances. ```rust fn eq(&self, other: &FollowInfo) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Get Default Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastLinkMicArmies.html Returns a static reference to the default, immutable instance of WebcastLinkMicArmies. ```rust fn default_instance() -> &'static WebcastLinkMicArmies; ``` -------------------------------- ### Get TikTokLive Room Info Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/core/live_client.rs.html Returns a reference to the client data for the current room. ```rust pub fn get_room_info(&self) -> &String { &self.room_info.client_data } ``` -------------------------------- ### Get Unknown Fields of QuestionDetails Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_question_new_message/struct.QuestionDetails.html Retrieves a reference to the unknown fields associated with the QuestionDetails message. ```rust fn unknown_fields(&self) -> &UnknownFields; ``` -------------------------------- ### Get Default Immutable Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.FanTicketRoomNoticeContent.html Returns a static, immutable reference to the default instance of FanTicketRoomNoticeContent. ```rust fn default_instance() -> &'static FanTicketRoomNoticeContent ``` -------------------------------- ### LinkmicInfo Clone Implementation Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/linker_reply_content/struct.LinkmicInfo.html Provides methods for creating copies of LinkmicInfo instances. Use `clone` for a simple copy and `clone_from` for in-place assignment. ```rust fn clone(&self) -> LinkmicInfo ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### WalletPackage Default Implementations Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/user/live_event_info/struct.WalletPackage.html Provides default implementations for WalletPackage, allowing for the creation of a default instance. This includes a default for a reference to WalletPackage and for WalletPackage itself. ```rust fn default() -> &'a WalletPackage ``` ```rust fn default() -> WalletPackage ``` -------------------------------- ### CohostListChangeContent::default() Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.CohostListChangeContent.html Provides the default value for CohostListChangeContent. Use this to get a default instance of the struct. ```rust fn default() -> CohostListChangeContent ``` -------------------------------- ### Get Default Immutable Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/badge_struct/struct.TextBadge.html Returns a static reference to the default immutable TextBadge message. ```rust fn default_instance() -> &'static TextBadge ``` -------------------------------- ### Get Default Immutable Message Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.TimeStampContainer.html Returns a static, immutable reference to the default TimeStampContainer message. ```rust fn default_instance() -> &'static TimeStampContainer ``` -------------------------------- ### ShopLabelImage Methods Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/user/ecommerce_entrance/shop_entrance_info/store_label/store_official_label/struct.ShopLabelImage.html Provides documentation for the `with_subscriber` and `with_current_subscriber` methods of the ShopLabelImage struct. ```APIDOC ## fn with_subscriber(self, subscriber: S) -> WithDispatch ### Description Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper. ### Method `with_subscriber` ### Parameters - **subscriber** (S) - Required - The subscriber to attach. `S` must implement `Into`. ### Returns - `WithDispatch` - A wrapper type containing the original type and the attached dispatch information. ``` ```APIDOC ## fn with_current_subscriber(self) -> WithDispatch ### Description Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper. ### Method `with_current_subscriber` ### Returns - `WithDispatch` - A wrapper type containing the original type and the attached dispatch information. ``` -------------------------------- ### KickOutBizContent Default Implementations Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/multi_live_content/struct.KickOutBizContent.html Provides default implementations for KickOutBizContent, allowing for the creation of default instances. This includes a default for borrowed references and owned values. ```rust fn default() -> &'a KickOutBizContent ``` ```rust fn default() -> KickOutBizContent ``` -------------------------------- ### Get FileDescriptor Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/fn.file_descriptor.html Returns a static reference to the FileDescriptor object. This object allows dynamic access to files. ```rust pub fn file_descriptor() -> &'static FileDescriptor ``` -------------------------------- ### LinkmicUserSettingInfo Initialization Check Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.LinkmicUserSettingInfo.html Checks if all required fields of the LinkmicUserSettingInfo object are initialized. This is crucial for ensuring data integrity before processing. ```rust pub fn check_initialized(&self) -> Result<(), Error> ``` -------------------------------- ### WebcastMsgDetectMessage Default Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastMsgDetectMessage.html Provides a default immutable instance of WebcastMsgDetectMessage. Useful for testing or as a starting point. ```rust fn default() -> &'a WebcastMsgDetectMessage ``` -------------------------------- ### ShowcaseEntranceInfo New Function Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/user/ecommerce_entrance/struct.ShowcaseEntranceInfo.html Provides a constructor to create a new, empty ShowcaseEntranceInfo instance. ```rust pub fn new() -> ShowcaseEntranceInfo ``` -------------------------------- ### Function Signature: create_default_settings Source: https://docs.rs/tiktoklive/latest/tiktoklive/data/fn.create_default_settings.html This snippet shows the function signature for `create_default_settings`. It takes a host name as a string slice and returns a `TikTokLiveSettings` object. ```rust pub fn create_default_settings(host_name: &str) -> TikTokLiveSettings ``` -------------------------------- ### Get Default Immutable QuestionDetails Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_question_new_message/struct.QuestionDetails.html Returns a static reference to the default, immutable instance of the QuestionDetails struct. ```rust fn default_instance() -> &'static QuestionDetails; ``` -------------------------------- ### RTCEngineConfig::new() Constructor Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/rtcextra_info/struct.RTCEngineConfig.html Provides a way to create a new, empty RTCEngineConfig instance. This is useful for initializing the configuration before setting its fields. ```rust pub fn new() -> RTCEngineConfig ``` -------------------------------- ### Get Special Fields Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastLinkMicArmies.html Retrieves a reference to the special fields, which include unknown fields and cached size information. ```rust fn special_fields(&self) -> &SpecialFields; ``` -------------------------------- ### PermitApplyContent::new() Function Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.PermitApplyContent.html Creates a new, empty instance of PermitApplyContent. This is a common constructor for message types. ```rust pub fn new() -> PermitApplyContent ``` -------------------------------- ### TikTokLiveBuilder::configure Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/core/live_client_builder.rs.html Allows for custom configuration of the live connection settings. ```APIDOC ## TikTokLiveBuilder::configure ### Description Configures the live connection settings by applying a closure that modifies the `TikTokLiveSettings`. ### Arguments * `on_configure` - A closure that takes a mutable reference to `TikTokLiveSettings` and applies custom configurations. ``` -------------------------------- ### LinkMicBattleDetails Message Trait - Cached Size and Writing Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_link_mic_battle/struct.LinkMicBattleDetails.html Provides methods to get the cached size and write the message to a stream. ```rust fn cached_size(&self) -> u32 ``` ```rust fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), Error> ``` -------------------------------- ### Create New WebcastLinkMicArmies Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastLinkMicArmies.html Constructs and returns a new, empty instance of the WebcastLinkMicArmies struct. ```rust fn new() -> WebcastLinkMicArmies; ``` -------------------------------- ### Create and Connect TikTokLive Client Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/lib.rs.html Use this snippet to create a new TikTokLive client instance for a specific user. The client can then be configured with event handlers and built before connecting to the live stream. ```rust use tiktoklive::TikTokLive; let client = TikTokLive::new_client("some-user"); // .configure(configure) // .on_event(on_event) // .build(); client.connect().await ``` -------------------------------- ### ReplyStatus Enum Implementation Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/generated/messages/enums.rs.html Provides the implementation for the ReplyStatus enum, including methods to get the integer value and convert from an integer. ```rust impl ::protobuf::Enum for ReplyStatus { const NAME: &'static str = "ReplyStatus"; fn value(&self) -> i32 { *self as i32 } fn from_i32(value: i32) -> ::std::option::Option { match value { 0 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_UNKNOWN), 1 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_AGREE), 2 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_PERSONALLY), 3 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_TYPE_NOT_SUPPORT), 4 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_PROCESSING_INVITATION), 5 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_BY_TIMEOUT), 6 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_EXCEPTION), 7 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_SYSTEM_NOT_SUPPORTED), 8 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_SUBTYPE_DIFFERENCE), 9 => ::std::option::Option::Some(ReplyStatus::REPLY_STATUS_REFUSE_IN_MICROOM) ``` -------------------------------- ### Create New WebcastSystemMessage Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastSystemMessage.html Provides a constructor function to create a new, empty instance of WebcastSystemMessage. This is useful for initializing message objects before populating them. ```rust pub fn new() -> WebcastSystemMessage ``` -------------------------------- ### Get Default Immutable Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastRoomMessage.html Returns a static reference to an immutable default WebcastRoomMessage. Useful for read-only access to a base instance. ```rust fn default_instance() -> &'static WebcastRoomMessage ``` -------------------------------- ### WalletPackage New Function Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/user/live_event_info/struct.WalletPackage.html Provides a constructor function to create a new instance of WalletPackage. This is a common pattern for initializing structs. ```rust pub fn new() -> WalletPackage ``` -------------------------------- ### Get Mutable Special Fields Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastLinkMicArmies.html Provides mutable access to the special fields, allowing modification of unknown fields and cached size. ```rust fn mut_special_fields(&mut self) -> &mut SpecialFields; ``` -------------------------------- ### Generated Enum Descriptor for OldSubscribeStatus Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/generated/messages/enums.rs.html Helper function to get the generated enum descriptor data for OldSubscribeStatus, used for protobuf reflection. ```rust impl OldSubscribeStatus { fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { ::protobuf::reflect::GeneratedEnumDescriptorData::new::("OldSubscribeStatus") } } ``` -------------------------------- ### Create New QuestionDetails Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_question_new_message/struct.QuestionDetails.html A function to create a new, empty instance of the QuestionDetails struct. ```rust fn new() -> QuestionDetails; ``` -------------------------------- ### Implement Default for WebcastRoomMessage Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastRoomMessage.html Provides a default instance for WebcastRoomMessage. Use this when you need a new, empty message object. ```rust fn default() -> WebcastRoomMessage ``` -------------------------------- ### LeaveContent::default() Implementation Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.LeaveContent.html Provides a default value for the LeaveContent struct itself. This is the standard way to get a zero-initialized or default state for the struct. ```rust fn default() -> LeaveContent ``` -------------------------------- ### RTCEngineConfig::default() for Owned Value Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/rtcextra_info/struct.RTCEngineConfig.html Returns a default RTCEngineConfig instance. This is the standard way to get a new, empty configuration object. ```rust fn default() -> RTCEngineConfig ``` -------------------------------- ### Implement Clone for WebcastSystemMessage Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastSystemMessage.html Enables creating a copy of a WebcastSystemMessage instance. The `clone` method returns a new instance with the same data, while `clone_from` performs in-place assignment. ```rust fn clone(&self) -> WebcastSystemMessage ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### PollStartContent Struct Definition Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.PollStartContent.html Defines the structure of a poll start content message, including start/end times, options, title, and operator. ```rust pub struct PollStartContent { pub StartTime: i64, pub EndTime: i64, pub OptionList: Vec, pub Title: String, pub Operator: MessageField, pub special_fields: SpecialFields, } ``` -------------------------------- ### Clone Implementation for FollowInfo Source: https://docs.rs/tiktoklive/latest/tiktoklive/data/live_common/struct.FollowInfo.html Provides methods to create a copy of a FollowInfo instance or copy-assign from another. ```rust fn clone(&self) -> FollowInfo ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Default Implementation for CreateChannelContent Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.CreateChannelContent.html Provides a default value for CreateChannelContent, useful for initialization. ```rust fn default() -> CreateChannelContent ``` -------------------------------- ### Get Default Immutable Message Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastQuestionNewMessage.html Returns a static reference to the default, immutable instance of WebcastQuestionNewMessage. This is a singleton pattern for default values. ```rust fn default_instance() -> &'static WebcastQuestionNewMessage ``` -------------------------------- ### Configure TikTokLiveSettings Source: https://docs.rs/tiktoklive/latest/tiktoklive/core/live_client_builder/struct.TikTokLiveBuilder.html Allows configuring the live connection settings using a closure. ```rust pub fn configure(&mut self, on_configure: F) -> &mut Self where F: FnOnce(&mut TikTokLiveSettings), ``` -------------------------------- ### Implement Clone for WebcastRoomMessage Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastRoomMessage.html Allows creating a copy of an existing WebcastRoomMessage. Use `clone` for a deep copy. ```rust fn clone(&self) -> WebcastRoomMessage ``` -------------------------------- ### Get Default Immutable Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastEnvelopeMessage.html Returns a pointer to the default immutable message instance with a static lifetime. This is a common pattern in protobuf implementations. ```rust fn default_instance() -> &'static WebcastEnvelopeMessage ``` -------------------------------- ### Get Default Immutable Message Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastBarrageMessage.html Returns a static reference to the default, immutable instance of WebcastBarrageMessage. This is often used for comparisons or as a base. ```rust fn default_instance() -> &'static WebcastBarrageMessage ``` -------------------------------- ### Fetch Live User Data Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/core/live_client_http.rs.html Retrieves live room information for a given user by their unique ID. Requires the user's name as input. ```rust pub async fn fetch_live_user_data( &self, request: LiveUserDataRequest, ) -> Result { let url = format!("{}{}", TIKTOK_URL_WEB, "api-live/user/room"); let option = self .factory .request() .with_url(url.as_str()) .with_param("uniqueId", request.user_name.as_str()) .with_param("sourceType", "54") .as_json() .await; let json = option.ok_or(LibError::HttpRequestFailed)?; map_live_user_data_response(json).map_err(|e| e) } ``` -------------------------------- ### Create New TextPieceUser Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/text/struct.TextPieceUser.html Provides a constructor to create a new, empty TextPieceUser instance. ```rust pub fn new() -> TextPieceUser ``` -------------------------------- ### Get Enum i32 Value Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/enums/enum.CommonContentCase.html Retrieves the integer representation of an enum variant. This is useful for serialization or when interacting with systems that use integer enums. ```rust fn value(&self) -> i32; ``` -------------------------------- ### LinkMicBattlePunishFinishData New Function Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_link_mic_battle_punish_finish/struct.LinkMicBattlePunishFinishData.html Creates a new, empty instance of LinkMicBattlePunishFinishData. ```rust pub fn new() -> LinkMicBattlePunishFinishData ``` -------------------------------- ### ComboBadgeInfo::default_instance() - Get Default Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/user/struct.ComboBadgeInfo.html Returns a pointer to the default immutable message instance with a static lifetime. This is part of the Message trait. ```rust fn default_instance() -> &'static ComboBadgeInfo ``` -------------------------------- ### PermitJoinGroupContent::new() Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.PermitJoinGroupContent.html Creates a new, empty instance of PermitJoinGroupContent. ```rust pub fn new() -> PermitJoinGroupContent ``` -------------------------------- ### Get Message Name Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastEnvelopeMessage.html Defines the static NAME constant for WebcastEnvelopeMessage, representing the message name as specified in the .proto file. This is useful for identifying the message type. ```rust const NAME: &'static str = "WebcastEnvelopeMessage" ``` -------------------------------- ### Protobuf Enum Implementation for SubscribingStatus Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/generated/messages/enums.rs.html Implements the protobuf::Enum trait for SubscribingStatus, providing methods to get the integer value, convert from an integer, and convert from a string. ```rust impl ::protobuf::Enum for SubscribingStatus { const NAME: &'static str = "SubscribingStatus"; fn value(&self) -> i32 { *self as i32 } fn from_i32(value: i32) -> ::std::option::Option { match value { 0 => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_UNKNOWN), 1 => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_ONCE), 2 => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_CIRCLE), 3 => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_CIRCLECANCEL), 4 => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_REFUND), 5 => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_INGRACEPERIOD), 6 => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_NOTINGRACEPERIOD), _ => ::std::option::Option::None } } fn from_str(str: &str) -> ::std::option::Option { match str { "SUBSCRIBINGSTATUS_UNKNOWN" => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_UNKNOWN), "SUBSCRIBINGSTATUS_ONCE" => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_ONCE), "SUBSCRIBINGSTATUS_CIRCLE" => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_CIRCLE), "SUBSCRIBINGSTATUS_CIRCLECANCEL" => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_CIRCLECANCEL), "SUBSCRIBINGSTATUS_REFUND" => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_REFUND), "SUBSCRIBINGSTATUS_INGRACEPERIOD" => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_INGRACEPERIOD), "SUBSCRIBINGSTATUS_NOTINGRACEPERIOD" => ::std::option::Option::Some(SubscribingStatus::SUBSCRIBINGSTATUS_NOTINGRACEPERIOD), _ => ::std::option::Option::None } } const VALUES: &'static [SubscribingStatus] = &[ SubscribingStatus::SUBSCRIBINGSTATUS_UNKNOWN, SubscribingStatus::SUBSCRIBINGSTATUS_ONCE, SubscribingStatus::SUBSCRIBINGSTATUS_CIRCLE, SubscribingStatus::SUBSCRIBINGSTATUS_CIRCLECANCEL, SubscribingStatus::SUBSCRIBINGSTATUS_REFUND, SubscribingStatus::SUBSCRIBINGSTATUS_INGRACEPERIOD, SubscribingStatus::SUBSCRIBINGSTATUS_NOTINGRACEPERIOD, ]; } ``` -------------------------------- ### TopHostInfo New Function Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/business_content/struct.TopHostInfo.html Provides a constructor for creating a new instance of TopHostInfo. ```rust pub fn new() -> TopHostInfo ``` -------------------------------- ### LiveUserDataResponse Struct Definition Source: https://docs.rs/tiktoklive/latest/tiktoklive/http/http_data/struct.LiveUserDataResponse.html Defines the structure for live user data response, including room ID, start time, user status, and JSON payload. ```rust pub struct LiveUserDataResponse { pub room_id: String, pub started_at_timestamp: i64, pub user_status: UserStatus, pub json: String, } ``` -------------------------------- ### MessageDetails New Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.MessageDetails.html Creates a new, empty MessageDetails instance. ```rust fn new() -> MessageDetails ``` -------------------------------- ### Default Implementation for LiveShoppingDetails Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_oec_live_shopping_message/struct.LiveShoppingDetails.html Provides a way to create a default instance of LiveShoppingDetails. ```rust fn default() -> LiveShoppingDetails ``` ```rust fn default() -> &'a LiveShoppingDetails ``` -------------------------------- ### Get Default Immutable Message Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/struct.WebcastSystemMessage.html Provides a static reference to the default immutable instance of WebcastSystemMessage. This is often used for read-only access to a base message state. ```rust fn default_instance() -> &'static WebcastSystemMessage ``` -------------------------------- ### LinkMessageType Enum Implementation Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/generated/messages/enums.rs.html Provides the implementation for the LinkMessageType enum, including methods to get the enum's name and convert from an i32 value. This is standard for protobuf-generated enums in Rust. ```rust impl ::protobuf::Enum for LinkMessageType { const NAME: &'static str = "LinkMessageType"; fn value(&self) -> i32 { *self as i32 } fn from_i32(value: i32) -> ::std::option::Option { match value { ``` -------------------------------- ### LinkerMediaChangeContent: new() Function Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.LinkerMediaChangeContent.html Provides a constructor for creating a new instance of LinkerMediaChangeContent. ```rust pub fn new() -> LinkerMediaChangeContent ``` -------------------------------- ### Clone To Uninit Method (Nightly) Source: https://docs.rs/tiktoklive/latest/tiktoklive/core/live_client_mapper/struct.TikTokLiveMessageMapper.html An experimental, nightly-only API for 'clone_to_uninit'. It performs copy-assignment from self to a raw pointer destination. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Get default immutable instance of LiveMessageSEI Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/common/struct.LiveMessageSEI.html Provides a static method `default_instance` to retrieve a pointer to a default, immutable `LiveMessageSEI` message with a static lifetime. This is useful for read-only access. ```rust fn default_instance() -> &'static LiveMessageSEI ``` -------------------------------- ### ActivityInfo Default Implementation Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/user/struct.ActivityInfo.html Provides a default value for ActivityInfo, allowing for easy initialization with standard settings. Also includes a default for references to ActivityInfo. ```rust fn default() -> ActivityInfo ``` ```rust fn default() -> &'a ActivityInfo ``` -------------------------------- ### Rust TimeInfo Struct Definition Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/webcast/webcast_msg_detect_message/struct.TimeInfo.html Defines the TimeInfo struct with fields for client start time, API receive time, API send to Goim time, and special fields. ```rust pub struct TimeInfo { pub clientStartMs: i64, pub apiRecvTimeMs: i64, pub apiSendToGoimMs: i64, pub special_fields: SpecialFields, } ``` -------------------------------- ### Rust TextPiece giftValue Methods Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/text/struct.TextPiece.html Provides methods to get, clear, check for, set, mutate, and take the gift-specific value within a TextPiece. These are used for managing gift-related data associated with the text piece. ```rust pub fn giftValue(&self) -> &TextPieceGift ``` ```rust pub fn clear_giftValue(&mut self) ``` ```rust pub fn has_giftValue(&self) -> bool ``` ```rust pub fn set_giftValue(&mut self, v: TextPieceGift) ``` ```rust pub fn mut_giftValue(&mut self) -> &mut TextPieceGift ``` ```rust pub fn take_giftValue(&mut self) -> TextPieceGift ``` -------------------------------- ### Goal New Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.Goal.html Creates a new, empty Goal message object. ```rust fn new() -> Goal { ``` -------------------------------- ### Rust TextPiece userValue Methods Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/text/struct.TextPiece.html Provides methods to get, clear, check for, set, mutate, and take the user-specific value within a TextPiece. These are used for managing user-related data associated with the text piece. ```rust pub fn userValue(&self) -> &TextPieceUser ``` ```rust pub fn clear_userValue(&mut self) ``` ```rust pub fn has_userValue(&self) -> bool ``` ```rust pub fn set_userValue(&mut self, v: TextPieceUser) ``` ```rust pub fn mut_userValue(&mut self) -> &mut TextPieceUser ``` ```rust pub fn take_userValue(&mut self) -> TextPieceUser ``` -------------------------------- ### Default Implementations for ReplyBizContent Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/multi_live_content/struct.ReplyBizContent.html Provides default values for ReplyBizContent, both for owned instances and references. This is useful for initializing new objects or providing a base state. ```rust fn default() -> ReplyBizContent ``` ```rust fn default() -> &'a ReplyBizContent ``` -------------------------------- ### GiftStruct Message Trait Implementations Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.GiftStruct.html Details the implementations of the Message trait for GiftStruct, covering functionalities like getting the message name, checking initialization, merging from streams, computing size, and writing to streams. ```rust const NAME: &'static str = "GiftStruct" ``` ```rust fn is_initialized(&self) -> bool ``` ```rust fn merge_from(&mut self, is: &mut CodedInputStream<'_>) -> Result<()> ``` ```rust fn compute_size(&self) -> u64 ``` ```rust fn write_to_with_cached_sizes( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()> ``` ```rust fn special_fields(&self) -> &SpecialFields ``` ```rust fn mut_special_fields(&mut self) -> &mut SpecialFields ``` ```rust fn new() -> GiftStruct ``` ```rust fn clear(&mut self) ``` ```rust fn default_instance() -> &'static GiftStruct ``` ```rust fn parse_from(is: &mut CodedInputStream<'_>) -> Result ``` ```rust fn cached_size(&self) -> u32 ``` ```rust fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), Error> ``` ```rust fn write_length_delimited_to( &self, os: &mut CodedOutputStream<'_>, ) -> Result<(), Error> ``` ```rust fn write_length_delimited_to_vec(&self, vec: &mut Vec) -> Result<(), Error> ``` ```rust fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), Error> ``` ```rust fn parse_from_reader(reader: &mut dyn Read) -> Result ``` ```rust fn parse_from_bytes(bytes: &[u8]) -> Result ``` ```rust fn parse_from_tokio_bytes(bytes: &Bytes) -> Result ``` ```rust fn check_initialized(&self) -> Result<(), Error> ``` -------------------------------- ### Message Trait Implementation for InviteContent Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.InviteContent.html Provides core message functionalities for InviteContent, such as getting the message name, checking initialization, merging from streams, computing size, writing to streams, and accessing special fields. ```rust impl Message for InviteContent { // ... other methods const NAME: &'static str = "InviteContent"; fn is_initialized(&self) -> bool; fn merge_from(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>; fn compute_size(&self) -> u64; fn write_to_with_cached_sizes( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()>; fn special_fields(&self) -> &SpecialFields; fn mut_special_fields(&mut self) -> &mut SpecialFields; fn new() -> InviteContent; fn clear(&mut self); fn default_instance() -> &'static InviteContent; fn parse_from(is: &mut CodedInputStream<'_>) -> Result; fn cached_size(&self) -> u32; fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<(), Error>; fn write_length_delimited_to( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()>; fn write_length_delimited_to_vec(&self, vec: &mut Vec) -> Result<()>; fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<()>; fn parse_from_reader(reader: &mut dyn Read) -> Result; fn parse_from_bytes(bytes: &[u8]) -> Result; fn parse_from_tokio_bytes(bytes: &Bytes) -> Result; fn check_initialized(&self) -> Result<(), Error>; fn write_to_writer(&self, w: &mut dyn Write) -> Result<()>; fn write_to_vec(&self, v: &mut Vec) -> Result<()>; fn write_to_bytes(&self) -> Result, Error>; fn write_length_delimited_to_writer( &self, w: &mut dyn Write, ) -> Result<()>; } ``` -------------------------------- ### Create Default Request Headers Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/data.rs.html Generates a HashMap of default headers for HTTP requests to TikTok Live. Includes common headers like 'authority', 'User-Agent', 'Referer', and 'Origin'. These headers are crucial for mimicking a legitimate browser request. ```rust fn create_default_headers() -> HashMap { let mut headers: Vec<(&str, &str)> = Vec::new(); headers.push(("authority", "www.core.com")); headers.push(("Cache-Control", "max-age=0")); headers.push(("Accept", "text/html,application/json,application/protobuf")); headers.push(("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36")); headers.push(("Referer", "https://www.tiktok.com/")); headers.push(("Origin", "https://www.tiktok.com")); headers.push(("Accept-Language", "en-US,en; q=0.9")); headers .iter() .map(|(key, value)| (key.to_string(), value.to_string())) .collect() } ``` -------------------------------- ### ProfileContent Message Trait - Default Instance and Parsing Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/badge_struct/struct.ProfileContent.html Details how to get a default immutable instance of ProfileContent and methods for parsing it from various sources. This includes parsing from streams, byte arrays, and Tokio Bytes. ```rust fn default_instance() -> &'static ProfileContent ``` ```rust fn parse_from(is: &mut CodedInputStream<'_>) -> Result ``` ```rust fn parse_from_bytes(bytes: &[u8]) -> Result ``` ```rust fn parse_from_tokio_bytes(bytes: &Bytes) -> Result ``` -------------------------------- ### HttpRequestBuilder: Build Client Source: https://docs.rs/tiktoklive/latest/tiktoklive/http/http_request_builder/struct.HttpRequestBuilder.html Builds and returns an HTTP client instance from the configured HttpRequestBuilder. This client can then be used to send requests. ```rust pub fn build_client(&mut self) -> Client ``` -------------------------------- ### TikTokLive::new_client Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/lib.rs.html Returns a builder for creating a new TikTokLive client instance. This is the primary entry point for setting up a client to connect to TikTok Live streams. ```APIDOC ## TikTokLive::new_client ### Description Returns a builder for creating a new TikTokLive client instance. This is the primary entry point for setting up a client to connect to TikTok Live streams. ### Method ```rust pub fn new_client(user_name: &str) -> TikTokLiveBuilder ``` ### Parameters * **user_name** (`&str`) - The username of the TikTok account to connect to. ### Returns A `TikTokLiveBuilder` instance, which can be used to further configure and build the TikTokLive client. ### Usage Example ```rust use tiktoklive::TikTokLive; let client = TikTokLive::new_client("some-user") // .configure(configure) // .on_event(on_event) .build(); // client.connect().await; ``` ``` -------------------------------- ### Enum Trait Implementations for LinkMessageType Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/enums/enum.LinkMessageType.html Provides core enum functionalities including getting the enum name, listing all values, and converting between integer and string representations. These methods are essential for working with enum types in the API. ```rust impl Enum for LinkMessageType Source #### fn NAME: &'static str = "LinkMessageType" Enum name as specified in `.proto` file. Read more Source #### fn VALUES: &'static [LinkMessageType] All enum values for enum type. Source #### fn value(&self) -> i32 Get enum `i32` value. Source #### fn from_i32(value: i32) -> Option Try to create an enum from `i32` value. Return `None` if value is unknown. Source #### fn from_str(str: &str) -> Option Try to create an enum from `&str` value. Return `None` if str is unknown. ``` -------------------------------- ### Map TikTok LIVE User Data Response Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/http/http_data_mappers.rs.html Parses a JSON string into a `LiveUserDataResponse` struct. Handles user status, room ID, and start time. Returns `LibError` for JSON parsing or missing fields. ```rust use crate::errors::LibError; use crate::http::http_data::LiveStatus::{HostNotFound, HostOffline, HostOnline}; use crate::http::http_data::UserStatus::{Live, LivePaused, NotFound, Offline}; use crate::http::http_data::{LiveDataResponse, LiveUserDataResponse, SignServerResponse}; use serde_json::Value; pub fn map_live_user_data_response(json: String) -> Result { let json_value: Value = serde_json::from_str(json.as_str()).map_err(|_| LibError::JsonParseError)?; let message = json_value["message"] .as_str() .ok_or(LibError::UserMessageFieldMissing)?; match message { "params_error" => return Err(LibError::ParamsError), "user_not_found" => return Err(LibError::UserNotFound), _ => {} } let option_data = json_value["data"] .as_object() .ok_or(LibError::UserDataFieldMissing)?; let user = option_data["user"] .as_object() .ok_or(LibError::UserFieldMissing)?; let room_id = user["roomId"] .as_str() .ok_or(LibError::RoomIDFieldMissing)?; let status = user["status"] .as_i64() .ok_or(LibError::UserStatusFieldMissing)?; let user_status = match status { 2 => Live, 3 => LivePaused, 4 => Offline, _ => NotFound, }; let live_room = option_data["liveRoom"] .as_object() .ok_or(LibError::LiveRoomFieldMissing)?; let start_time = live_room["startTime"] .as_i64() .ok_or(LibError::StartTimeFieldMissing)?; Ok(LiveUserDataResponse { user_status, json, room_id: room_id.to_string(), started_at_timestamp: start_time, }) } ``` -------------------------------- ### CohostContent::clone() Implementation Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/business_content/struct.CohostContent.html Provides a way to create a copy of an existing CohostContent instance. Useful for duplicating data. ```rust fn clone(&self) -> CohostContent ``` -------------------------------- ### Create Default TikTokLive Settings Source: https://docs.rs/tiktoklive/latest/src/tiktoklive/data.rs.html Generates a default TikTokLiveSettings struct with common configurations for language, API keys, logging, reconnection, and HTTP data. Use this as a starting point for customizing live stream settings. ```rust use std::collections::HashMap; use std::time::Duration; use crate::data::live_common::{HttpData, TikTokLiveSettings}; pub mod live_common; pub fn create_default_settings(host_name: &str) -> TikTokLiveSettings { TikTokLiveSettings { language: "en-US".to_string(), sign_api_key: "".to_string(), print_logs: true, reconnect_on_fail: true, host_name: host_name.to_string(), http_data: HttpData { time_out: Duration::from_secs(3), cookies: create_default_cookies(), headers: create_default_headers(), params: create_default_params(), }, } } ``` -------------------------------- ### ActivityInfo New Function Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/user/struct.ActivityInfo.html Provides a constructor to create a new, empty instance of ActivityInfo. Useful for initializing activity data. ```rust pub fn new() -> ActivityInfo ``` -------------------------------- ### Create New LinkerUpdateUserSettingContent Instance Source: https://docs.rs/tiktoklive/latest/tiktoklive/generated/messages/data/struct.LinkerUpdateUserSettingContent.html Provides a method to create a new, empty instance of LinkerUpdateUserSettingContent. This is useful for initializing the struct. ```rust pub fn new() -> LinkerUpdateUserSettingContent ```