pub fn servers(&mut self, prune_dead: bool) -> Result<Vec<PlexMediaServer>, Error> {
        let res = self.client
            .get("https://plex.tv/pms/servers.xml")
            .headers(self.headers.clone())
            .send()?;

        // TODO(csssuf): This is a lazy way of dealing with the fact that error-chain errors aren't
        // Sync and so don't compose well with failure and I'm not interested in shaving *that*
        // particular yak right now.
        // Fix this when serde-xml-rs switches to failure or error-chain comes up with something
        // for interop with failure or something.
        let res_struct: MediaContainer = match serde_xml_rs::from_reader(res) {
            Ok(s) => s,
            Err(e) => bail!("deserialization error: {}", e),
        };
        let mut out = Vec::new();

        for server in res_struct.servers {
            let mut headers = self.headers.clone();
            if server.access_token != "" {
                headers.set(XPlexToken(server.access_token.clone()));
            }

            let client = ClientBuilder::new()
                .default_headers(headers)
                .timeout(Duration::from_secs(2))
                .build()?;

            if prune_dead && client
                .get(&format!("{}://{}:{}/", server.scheme, server.address, server.port))
                .send()
                .is_err()
            {
                continue;
            }

            out.push(PlexMediaServer::new(
                client,
                server,
            ));
        }

        Ok(out)
    }
/// Fetch a list of accessible servers from plex.tv.
///
/// If `prune_dead` is set, this function will only include those it is currently able to
/// contact. However, this requires generating a request to each server and waiting for it to
/// time out, which slows this function down considerably.
Fetch a list of accessible servers from plex.tv.
If `prune_dead` is set, this function will only include those it is currently able to
contact. However, this requires generating a request to each server and waiting for it to
time out, which slows this function down considerably.
Fetch a list of accessible servers from plex . tv . If ` prune_dead ` is set this function will only include those it is currently able to contact . However this requires generating a request to each server and waiting for it to time out which slows this function down considerably .
pub fn servers(&mut self, prune_dead: bool) -> Result<Vec<PlexMediaServer>, Error> {
        let res = self.client
            .get("https://plex.tv/pms/servers.xml")
            .headers(self.headers.clone())
            .send()?;
        // TODO(csssuf): This is a lazy way of dealing with the fact that error-chain errors aren't
        // Sync and so don't compose well with failure and I'm not interested in shaving *that*
        // particular yak right now.
        // Fix this when serde-xml-rs switches to failure or error-chain comes up with something
        // for interop with failure or something.
        let res_struct: MediaContainer = match serde_xml_rs::from_reader(res) {
            Ok(s) => s,
            Err(e) => bail!("deserialization error: {}", e),
        };
        let mut out = Vec::new();
        for server in res_struct.servers {
            let mut headers = self.headers.clone();
            if server.access_token != "" {
                headers.set(XPlexToken(server.access_token.clone()));
            }
            let client = ClientBuilder::new()
                .default_headers(headers)
                .timeout(Duration::from_secs(2))
                .build()?;
            if prune_dead && client
                .get(&format!("{}://{}:{}/", server.scheme, server.address, server.port))
                .send()
                .is_err()
            {
                continue;
            }
            out.push(PlexMediaServer::new(
                client,
                server,
            ));
        }
        Ok(out)
    }
pub fn servers ( & mut self , prune_dead : bool ) -> Result < Vec < PlexMediaServer > , Error > { let res = self . client . get ( " " ) . headers ( self . headers . clone ( ) ) . send ( ) ? ; // TODO(csssuf): This is a lazy way of dealing with the fact that error-chain errors aren't // Sync and so don't compose well with failure and I'm not interested in shaving *that* // particular yak right now. // Fix this when serde-xml-rs switches to failure or error-chain comes up with something // for interop with failure or something. let res_struct : MediaContainer = match serde_xml_rs :: from_reader ( res ) { Ok ( s ) => s , Err ( e ) => bail ! ( " " e ) , } ; let mut out = Vec :: new ( ) ; for server in res_struct . servers { let mut headers = self . headers . clone ( ) ; if server . access_token != " " { headers . set ( XPlexToken ( server . access_token . clone ( ) ) ) ; } let client = ClientBuilder :: new ( ) . default_headers ( headers ) . timeout ( Duration :: from_secs ( 2 ) ) . build ( ) ? ; if prune_dead && client . get ( & format ! ( " " server scheme server address server port ) ) . send ( ) . is_err ( ) { continue ; } out . push ( PlexMediaServer :: new ( client , server , ) ) ; } Ok ( out ) }
Fetch a list of accessible servers from plex.tv.
Fetch a list of accessible servers from plex . tv .
&mut self
prune_dead
bool
&mut self
prune_dead
bool