Struct sip2::Client

source ·
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(&params).expect("Login Error").ok() {
    true => println!("Login OK"),
    false => eprintln!("Login Failed"),
}

Implementations§

source§

impl Client

source

pub fn new(host: &str) -> Result<Self, Error>

Creates a new SIP client and opens the TCP connection to the server.

source

pub fn disconnect(&self) -> Result<(), Error>

Shutdown the TCP connection with the SIP server.

source

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.

source

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.

source

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”

source

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”

source

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.

source

pub fn checkout(&mut self, params: &ParamSet) -> Result<SipResponse, Error>

Send a CHECKOUT request

source

pub fn checkin(&mut self, params: &ParamSet) -> Result<SipResponse, Error>

Send a CHECKIN request

source

pub fn fee_paid(&mut self, params: &ParamSet) -> Result<SipResponse, Error>

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.