Struct lapin_async::connection::Connection
[−]
[src]
pub struct Connection { pub state: ConnectionState, pub channels: HashMap<u16, Channel>, pub configuration: Configuration, pub channel_index: u16, pub prefetch_size: u32, pub prefetch_count: u16, pub frame_queue: VecDeque<Frame>, pub request_index: RequestId, pub finished_reqs: HashSet<RequestId>, pub finished_get_reqs: HashMap<RequestId, bool>, pub credentials: Option<Credentials>, }
Fields
state: ConnectionState
current state of the connection. In normal use it should always be ConnectionState::Connected
channels: HashMap<u16, Channel>
configuration: Configuration
channel_index: u16
prefetch_size: u32
prefetch_count: u16
frame_queue: VecDeque<Frame>
list of message to send
request_index: RequestId
next request id
finished_reqs: HashSet<RequestId>
list of finished requests
finished_get_reqs: HashMap<RequestId, bool>
list of finished basic get requests
credentials: Option<Credentials>
credentials are stored in an option to remove them from memory once they are used
Methods
impl Connection
[src]
fn run<T>(&mut self,
stream: &mut T,
send_buffer: &mut Buffer,
receive_buffer: &mut Buffer)
-> Result<ConnectionState> where T: Read + Write
stream: &mut T,
send_buffer: &mut Buffer,
receive_buffer: &mut Buffer)
-> Result<ConnectionState> where T: Read + Write
helper function to handle reading and writing repeatedly from the network until there's no more state to update
fn can_write(&self, send_buffer: &Buffer) -> bool
tests whether we can write to the send buffer
fn can_read(&self, receive_buffer: &Buffer) -> bool
tests whether we can read from the receive buffer
fn can_parse(&self, receive_buffer: &Buffer) -> bool
tests whether we can parse data from the receive buffer
fn write_to_stream(&mut self,
writer: &mut Write,
send_buffer: &mut Buffer)
-> Result<(usize, ConnectionState)>
writer: &mut Write,
send_buffer: &mut Buffer)
-> Result<(usize, ConnectionState)>
serializes frames to the send buffer then to the writer (if possible)
fn read_from_stream(&mut self,
reader: &mut Read,
receive_buffer: &mut Buffer)
-> Result<(usize, ConnectionState)>
reader: &mut Read,
receive_buffer: &mut Buffer)
-> Result<(usize, ConnectionState)>
read data from the network into the receive buffer
impl Connection
[src]
fn new() -> Connection
creates a Connection
object in initial state
fn set_credentials(&mut self, username: &str, password: &str)
fn set_heartbeat(&mut self, heartbeat: u16)
fn create_channel(&mut self) -> u16
creates a Channel
object in initial state
returns a u16
channel id
The channel will not be usable until channel_open
is called with the channel id
fn set_channel_state(&mut self, channel_id: u16, new_state: ChannelState)
fn check_state(&self, channel_id: u16, state: ChannelState) -> Option<bool>
verifies if the channel's state is the one passed as argument
returns a Option of the result. None in the case the channel does not exists
fn get_state(&self, channel_id: u16) -> Option<ChannelState>
returns the channel's state
returns a Option of the state. Non in the case the channel does not exists
fn is_connected(&self, channel_id: u16) -> bool
verifies if the channel is connecyed
fn is_finished(&mut self, id: RequestId) -> bool
verifies if the request identified with the RequestId
is finished
this method can only be called once per request id, as it will be removed from the list afterwards
fn finished_get_result(&mut self, id: RequestId) -> Option<bool>
verifies if the get request identified with the RequestId
is finished
this method can only be called once per request id, as it will be removed from the list afterwards
fn next_message(&mut self,
channel_id: u16,
queue_name: &str,
consumer_tag: &str)
-> Option<Message>
channel_id: u16,
queue_name: &str,
consumer_tag: &str)
-> Option<Message>
gets the next message corresponding to a channel, queue and consumer tag
if the channel id, queue and consumer tag have no link, the method will return None. If there is no message, the method will return None
fn next_get_message(&mut self,
channel_id: u16,
queue_name: &str)
-> Option<Message>
channel_id: u16,
queue_name: &str)
-> Option<Message>
gets the next message corresponding to a channel and queue, in response to a basic.get
if the channel id and queue have no link, the method will return None. If there is no message, the method will return None
fn connect(&mut self) -> Result<ConnectionState>
starts the process of connecting to the server
this will set up the state machine and generates the required messages.
The messages will not be sent until calls to serialize
to write the messages to a buffer, or calls to next_frame
to obtain the next message to send
fn next_frame(&mut self) -> Option<Frame>
next message to send to the network
returns None if there's no message to send
fn serialize(&mut self,
send_buffer: &mut [u8])
-> Result<(usize, ConnectionState)>
send_buffer: &mut [u8])
-> Result<(usize, ConnectionState)>
writes the next message to a mutable byte slice
returns how many bytes were written and the current state. this method can be called repeatedly until the buffer is full or there are no more frames to send
fn parse(&mut self, data: &[u8]) -> Result<(usize, ConnectionState)>
parses a frame from a byte slice
returns how many bytes were consumed and the current state.
This method will update the state machine according to the ReceivedStart
frame with handle_frame
fn handle_frame(&mut self, f: Frame)
updates the current state with a new received frame
fn send_content_frames(&mut self,
channel_id: u16,
class_id: u16,
slice: &[u8],
properties: Properties)
channel_id: u16,
class_id: u16,
slice: &[u8],
properties: Properties)
generates the content header and content frames for a payload
the frames will be stored in the frame queue until they're written to the network.
impl Connection
[src]
fn receive_method(&mut self,
channel_id: u16,
method: Class)
-> Result<(), Error>
channel_id: u16,
method: Class)
-> Result<(), Error>
fn channel_open(&mut self,
_channel_id: u16,
out_of_band: ShortString)
-> Result<RequestId, Error>
_channel_id: u16,
out_of_band: ShortString)
-> Result<RequestId, Error>
fn receive_channel_open_ok(&mut self,
_channel_id: u16,
_: OpenOk)
-> Result<(), Error>
_channel_id: u16,
_: OpenOk)
-> Result<(), Error>
fn channel_flow(&mut self,
_channel_id: u16,
active: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
active: Boolean)
-> Result<RequestId, Error>
fn receive_channel_flow(&mut self,
_channel_id: u16,
method: Flow)
-> Result<(), Error>
_channel_id: u16,
method: Flow)
-> Result<(), Error>
fn channel_flow_ok(&mut self,
_channel_id: u16,
active: Boolean)
-> Result<(), Error>
_channel_id: u16,
active: Boolean)
-> Result<(), Error>
fn receive_channel_flow_ok(&mut self,
_channel_id: u16,
method: FlowOk)
-> Result<(), Error>
_channel_id: u16,
method: FlowOk)
-> Result<(), Error>
fn channel_close(&mut self,
_channel_id: u16,
reply_code: ShortUInt,
reply_text: ShortString,
class_id: ShortUInt,
method_id: ShortUInt)
-> Result<RequestId, Error>
_channel_id: u16,
reply_code: ShortUInt,
reply_text: ShortString,
class_id: ShortUInt,
method_id: ShortUInt)
-> Result<RequestId, Error>
fn receive_channel_close(&mut self,
_channel_id: u16,
_: Close)
-> Result<(), Error>
_channel_id: u16,
_: Close)
-> Result<(), Error>
fn channel_close_ok(&mut self, _channel_id: u16) -> Result<(), Error>
fn receive_channel_close_ok(&mut self,
_channel_id: u16,
_: CloseOk)
-> Result<(), Error>
_channel_id: u16,
_: CloseOk)
-> Result<(), Error>
fn queue_declare(&mut self,
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
passive: Boolean,
durable: Boolean,
exclusive: Boolean,
auto_delete: Boolean,
nowait: Boolean,
arguments: FieldTable)
-> Result<RequestId, Error>
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
passive: Boolean,
durable: Boolean,
exclusive: Boolean,
auto_delete: Boolean,
nowait: Boolean,
arguments: FieldTable)
-> Result<RequestId, Error>
fn receive_queue_declare_ok(&mut self,
_channel_id: u16,
method: DeclareOk)
-> Result<(), Error>
_channel_id: u16,
method: DeclareOk)
-> Result<(), Error>
fn queue_bind(&mut self,
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
exchange: ShortString,
routing_key: ShortString,
nowait: Boolean,
arguments: FieldTable)
-> Result<RequestId, Error>
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
exchange: ShortString,
routing_key: ShortString,
nowait: Boolean,
arguments: FieldTable)
-> Result<RequestId, Error>
fn receive_queue_bind_ok(&mut self,
_channel_id: u16,
_: BindOk)
-> Result<(), Error>
_channel_id: u16,
_: BindOk)
-> Result<(), Error>
fn queue_purge(&mut self,
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
nowait: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
nowait: Boolean)
-> Result<RequestId, Error>
fn receive_queue_purge_ok(&mut self,
_channel_id: u16,
_: PurgeOk)
-> Result<(), Error>
_channel_id: u16,
_: PurgeOk)
-> Result<(), Error>
fn queue_delete(&mut self,
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
if_unused: Boolean,
if_empty: Boolean,
nowait: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
if_unused: Boolean,
if_empty: Boolean,
nowait: Boolean)
-> Result<RequestId, Error>
fn receive_queue_delete_ok(&mut self,
_channel_id: u16,
_: DeleteOk)
-> Result<(), Error>
_channel_id: u16,
_: DeleteOk)
-> Result<(), Error>
fn queue_unbind(&mut self,
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
exchange: ShortString,
routing_key: ShortString,
arguments: FieldTable)
-> Result<RequestId, Error>
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
exchange: ShortString,
routing_key: ShortString,
arguments: FieldTable)
-> Result<RequestId, Error>
fn receive_queue_unbind_ok(&mut self,
_channel_id: u16,
_: UnbindOk)
-> Result<(), Error>
_channel_id: u16,
_: UnbindOk)
-> Result<(), Error>
fn basic_qos(&mut self,
_channel_id: u16,
prefetch_size: LongUInt,
prefetch_count: ShortUInt,
global: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
prefetch_size: LongUInt,
prefetch_count: ShortUInt,
global: Boolean)
-> Result<RequestId, Error>
fn receive_basic_qos_ok(&mut self,
_channel_id: u16,
_: QosOk)
-> Result<(), Error>
_channel_id: u16,
_: QosOk)
-> Result<(), Error>
fn basic_consume(&mut self,
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
consumer_tag: ShortString,
no_local: Boolean,
no_ack: Boolean,
exclusive: Boolean,
nowait: Boolean,
arguments: FieldTable)
-> Result<RequestId, Error>
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
consumer_tag: ShortString,
no_local: Boolean,
no_ack: Boolean,
exclusive: Boolean,
nowait: Boolean,
arguments: FieldTable)
-> Result<RequestId, Error>
fn receive_basic_consume_ok(&mut self,
_channel_id: u16,
method: ConsumeOk)
-> Result<(), Error>
_channel_id: u16,
method: ConsumeOk)
-> Result<(), Error>
fn basic_cancel(&mut self,
_channel_id: u16,
consumer_tag: ShortString,
nowait: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
consumer_tag: ShortString,
nowait: Boolean)
-> Result<RequestId, Error>
fn receive_basic_cancel_ok(&mut self,
_channel_id: u16,
method: CancelOk)
-> Result<(), Error>
_channel_id: u16,
method: CancelOk)
-> Result<(), Error>
fn basic_publish(&mut self,
_channel_id: u16,
ticket: ShortUInt,
exchange: ShortString,
routing_key: ShortString,
mandatory: Boolean,
immediate: Boolean)
-> Result<u64, Error>
_channel_id: u16,
ticket: ShortUInt,
exchange: ShortString,
routing_key: ShortString,
mandatory: Boolean,
immediate: Boolean)
-> Result<u64, Error>
fn receive_basic_amqp_return(&mut self,
_channel_id: u16,
_: Return)
-> Result<(), Error>
_channel_id: u16,
_: Return)
-> Result<(), Error>
fn receive_basic_deliver(&mut self,
_channel_id: u16,
method: Deliver)
-> Result<(), Error>
_channel_id: u16,
method: Deliver)
-> Result<(), Error>
fn basic_get(&mut self,
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
no_ack: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
ticket: ShortUInt,
queue: ShortString,
no_ack: Boolean)
-> Result<RequestId, Error>
fn receive_basic_get_ok(&mut self,
_channel_id: u16,
method: GetOk)
-> Result<(), Error>
_channel_id: u16,
method: GetOk)
-> Result<(), Error>
fn receive_basic_get_empty(&mut self,
_channel_id: u16,
_: GetEmpty)
-> Result<(), Error>
_channel_id: u16,
_: GetEmpty)
-> Result<(), Error>
fn basic_ack(&mut self,
_channel_id: u16,
delivery_tag: LongLongUInt,
multiple: Boolean)
-> Result<(), Error>
_channel_id: u16,
delivery_tag: LongLongUInt,
multiple: Boolean)
-> Result<(), Error>
fn basic_reject(&mut self,
_channel_id: u16,
delivery_tag: LongLongUInt,
requeue: Boolean)
-> Result<(), Error>
_channel_id: u16,
delivery_tag: LongLongUInt,
requeue: Boolean)
-> Result<(), Error>
fn basic_recover_async(&mut self,
_channel_id: u16,
requeue: Boolean)
-> Result<(), Error>
_channel_id: u16,
requeue: Boolean)
-> Result<(), Error>
fn basic_recover(&mut self,
_channel_id: u16,
requeue: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
requeue: Boolean)
-> Result<RequestId, Error>
fn receive_basic_recover_ok(&mut self,
_channel_id: u16,
_: RecoverOk)
-> Result<(), Error>
_channel_id: u16,
_: RecoverOk)
-> Result<(), Error>
fn basic_nack(&mut self,
_channel_id: u16,
delivery_tag: LongLongUInt,
multiple: Boolean,
requeue: Boolean)
-> Result<(), Error>
_channel_id: u16,
delivery_tag: LongLongUInt,
multiple: Boolean,
requeue: Boolean)
-> Result<(), Error>
fn confirm_select(&mut self,
_channel_id: u16,
nowait: Boolean)
-> Result<RequestId, Error>
_channel_id: u16,
nowait: Boolean)
-> Result<RequestId, Error>
fn receive_confirm_select_ok(&mut self,
_channel_id: u16,
method: SelectOk)
-> Result<(), Error>
_channel_id: u16,
method: SelectOk)
-> Result<(), Error>
fn receive_basic_ack(&mut self,
_channel_id: u16,
method: Ack)
-> Result<(), Error>
_channel_id: u16,
method: Ack)
-> Result<(), Error>
fn receive_basic_nack(&mut self,
_channel_id: u16,
method: Nack)
-> Result<(), Error>
_channel_id: u16,
method: Nack)
-> Result<(), Error>
Trait Implementations
impl Clone for Connection
[src]
fn clone(&self) -> Connection
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Connection
[src]
impl PartialEq for Connection
[src]
fn eq(&self, __arg_0: &Connection) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Connection) -> bool
This method tests for !=
.