pub fn with_type(socket_type: CrasSocketType) -> Result<Self> {
        // Create a connection to the server.
        let mut server_socket = CrasServerSocket::with_type(socket_type)?;
        // Gets client ID and server state fd from server
        if let ServerResult::Connected(client_id, server_state_fd) =
            CrasClient::wait_for_message(&mut server_socket)?
        {
            Ok(Self {
                server_socket,
                server_state: CrasServerState::try_new(server_state_fd)?,
                client_id,
                next_stream_id: 0,
                cras_capture: false,
                client_type: CRAS_CLIENT_TYPE::CRAS_CLIENT_TYPE_UNKNOWN,
            })
        } else {
            Err(Error::MessageTypeError)
        }
    }
/// Tries to create a `CrasClient` with a given `CrasSocketType`.
///
/// # Errors
///
/// Returns error if error occurs while handling server message or message
/// type is incorrect.
Tries to create a `CrasClient` with a given `CrasSocketType`.
Tries to create a ` CrasClient ` with a given ` CrasSocketType ` .
pub fn with_type(socket_type: CrasSocketType) -> Result<Self> {
        // Create a connection to the server.
        let mut server_socket = CrasServerSocket::with_type(socket_type)?;
        // Gets client ID and server state fd from server
        if let ServerResult::Connected(client_id, server_state_fd) =
            CrasClient::wait_for_message(&mut server_socket)?
        {
            Ok(Self {
                server_socket,
                server_state: CrasServerState::try_new(server_state_fd)?,
                client_id,
                next_stream_id: 0,
                cras_capture: false,
                client_type: CRAS_CLIENT_TYPE::CRAS_CLIENT_TYPE_UNKNOWN,
            })
        } else {
            Err(Error::MessageTypeError)
        }
    }
pub fn with_type ( socket_type : CrasSocketType ) -> Result < Self > { // Create a connection to the server. let mut server_socket = CrasServerSocket :: with_type ( socket_type ) ? ; // Gets client ID and server state fd from server if let ServerResult :: Connected ( client_id , server_state_fd ) = CrasClient :: wait_for_message ( & mut server_socket ) ? { Ok ( Self { server_socket , server_state : CrasServerState :: try_new ( server_state_fd ) ? , client_id , next_stream_id : 0 , cras_capture : false , client_type : CRAS_CLIENT_TYPE :: CRAS_CLIENT_TYPE_UNKNOWN , } ) } else { Err ( Error :: MessageTypeError ) } }
Tries to create a `CrasClient` with a given `CrasSocketType`.
Tries to create a ` CrasClient ` with a given ` CrasSocketType ` .
socket_type
CrasSocketType
socket_type
CrasSocketType
errors
Returns error if error occurs while handling server message or message
type is incorrect.
Returns error if error occurs while handling server message or message type is incorrect .