Struct wmclient::WmClient [−][src]
pub struct WmClient {
pub static_caps: Vec<String>,
pub virtual_caps: Vec<String>,
pub important_headers: Vec<String>,
// some fields omitted
}
Expand description
Client that interacts with a WURFL Microservice server (be it a docker image or a AWS/Azure or GCP virtual machine. This client exposes device lookup methods and some “enumration” methods, such as those for getting all OS names or all device brands used by the WURFL Microservice.
Fields
static_caps: Vec<String>
virtual_caps: Vec<String>
important_headers: Vec<String>
Implementations
Creates a new instance of the WURFL microservice client. Basic usage:
use wmclient::WmClient;
let client = WmClient::new("http", "localhost", "8080", "");
Returns the version of this Rust client API
sets the overall HTTP timeout in milliseconds
returns true if WURFL microservice exposes the static capability with name cap_name
, false otherwise
returns true if WURFL microservice exposes the virtual capability with name cap_name
, false otherwise
Returns a struct containing info about the running WURFL Microservice server to which this client is connected Basic usage:
use wmclient::WmClient;
let client = WmClient::new("http", "localhost", "8080", "");
let info_res = client.unwrap().get_info();
if info_res.is_err(){
// handle error...
}
let info = info_res.unwrap();
println!("Server version: {}", info.wm_version);
println!("WURFL API version: {}", info.wurfl_api_version);
println!("WURFL file info: {}", info.wurfl_info);
lookup_useragent - Searches WURFL device data using the given user-agent for detection. Passing an empty string as user-agent will return a “generic” device.
lookup_device_id - Searches WURFL device data using its wurfl_id value. Passing an empty or not existing wurfl_id value will make client return a WmError
pub fn lookup_headers<U, V, T: IntoIterator<Item = (U, V)>>(
&mut self,
in_headers: T
) -> Result<JSONDeviceData, WmError> where
U: ToString,
V: AsRef<[u8]>,
pub fn lookup_headers<U, V, T: IntoIterator<Item = (U, V)>>(
&mut self,
in_headers: T
) -> Result<JSONDeviceData, WmError> where
U: ToString,
V: AsRef<[u8]>,
lookup_headers - Performs a device detection based on HTTP request headers that can be passed in any data structures that implement the
IntoIterator
trait (for example: HashMap or Hyper framework HeaderMap.
Clear all the caches in this client
Sets the new cache size. Changing cache size will result in a cache purge.
set_requested_static_capabilities - set list of standard static capabilities to return with the detected device. A device struct returned by the client may have up to 500 capabilities. This method is used mainly to limit the returned static capabilities to the ones you really need.
set_requested_virtual_capabilities - set list of standard virtual capabilities to return with the detected device. A device struct returned by the client may have up to 500 capabilities. This method is used mainly to limit the returned virtual capabilities to the ones you really need.
set_requested_capabilities - set list of standard capabilities to return with the detected device. Using this method you don’t have to know if the requested capability is either static or virtual, the method assigns the capability to the set it belongs.
get_actual_cache_sizes returns the values of cache size. The first value being the device-id based cache, the second value being the size of the headers-based one
get_all_oses returns a vec
Return a Vecos_name
.
It returns a WmError i case the given os_name
does not exist
Returns the list of all device manufacturers in WURFL Microservice
pub fn get_all_devices_for_make(
&self,
brand_name: String
) -> Result<Vec<JSONModelMktName>, WmError>
pub fn get_all_devices_for_make(
&self,
brand_name: String
) -> Result<Vec<JSONModelMktName>, WmError>
Returns a list of structs that hold data about model a device and marketing names for the given brand_name
.
The method returns a WmError in case the brand_name
does not exist.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for WmClient
impl !UnwindSafe for WmClient
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more