pub struct Client { /* private fields */ }
Expand description
Wrapper for Connection which provides a simpler interface for some common SIP2 actions.
This is not a complete set of friendly-ified requests. Just a start.
use sip2::{Client, ParamSet};
let mut client = Client::new("127.0.0.1:6001").expect("Cannot Connect");
let mut params = ParamSet::new();
params.set_sip_user("sip-server-login");
params.set_sip_pass("sip-server-password");
// Login to the SIP server
match client.login(¶ms).expect("Login Error").ok() {
true => println!("Login OK"),
false => eprintln!("Login Failed"),
}
Implementations§
source§impl Client
impl Client
sourcepub fn new(host: &str) -> Result<Self, Error>
pub fn new(host: &str) -> Result<Self, Error>
Creates a new SIP client and opens the TCP connection to the server.
sourcepub fn disconnect(&self) -> Result<(), Error>
pub fn disconnect(&self) -> Result<(), Error>
Shutdown the TCP connection with the SIP server.
sourcepub fn login(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
pub fn login(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
Login to the SIP server
Sets ok=true if the OK fixed field is true.
sourcepub fn sc_status(&mut self) -> Result<SipResponse, Error>
pub fn sc_status(&mut self) -> Result<SipResponse, Error>
Send the SC status message
Sets ok=true if the server reports that it’s online.
sourcepub fn patron_status(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
pub fn patron_status(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
Send a patron status request
Sets ok=true if the “valid patron” (BL) field is “Y”
sourcepub fn patron_info(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
pub fn patron_info(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
Send a patron information request
Sets ok=true if the “valid patron” (BL) field is “Y”
sourcepub fn item_info(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
pub fn item_info(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
Send a item information request
Sets ok=true if a title (AJ) value is present. Oddly, there’s no specific “item does not exist” value in the Item Info Response.
sourcepub fn checkout(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
pub fn checkout(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
Send a CHECKOUT request
sourcepub fn checkin(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
pub fn checkin(&mut self, params: &ParamSet) -> Result<SipResponse, Error>
Send a CHECKIN request