Struct haproxy_api::Channel

source ·
pub struct Channel<'lua> { /* private fields */ }
Expand description

The “Channel” class contains all functions to manipulate channels.

Please refer to HAProxy documentation to get more information.

Implementations§

source§

impl<'lua> Channel<'lua>

source

pub fn append(&self, data: impl AsRef<[u8]>) -> Result<isize>

Copies the string string at the end of incoming data of the channel buffer. Returns the copied length on success or -1 if data cannot be copied.

source

pub fn data( &self, offset: Option<isize>, length: Option<isize> ) -> Result<Option<LuaString<'_>>>

Returns length bytes of incoming data from the channel buffer, starting at the offset. The data are not removed from the buffer.

source

pub fn forward(&self, length: usize) -> Result<usize>

Forwards length bytes of data from the channel buffer. Returns the amount of data forwarded and must not be called from an action to avoid yielding.

source

pub fn input(&self) -> Result<usize>

Returns the length of incoming data in the channel buffer.

source

pub fn insert( &self, data: impl AsRef<[u8]>, offset: Option<isize> ) -> Result<isize>

Copies the data at the offset in incoming data of the channel buffer. Returns the copied length on success or -1 if data cannot be copied.

By default, if no offset is provided, the string is copied in front of incoming data. A positive offset is relative to the beginning of incoming data of the channel buffer while negative offset is relative to their end.

source

pub fn is_full(&self) -> Result<bool>

Returns true if the channel buffer is full.

source

pub fn is_resp(&self) -> Result<bool>

Returns true if the channel is the response one.

source

pub fn line( &self, offset: Option<isize>, length: Option<isize> ) -> Result<Option<LuaString<'_>>>

Parses length bytes of incoming data of the channel buffer, starting at offset, and returns the first line found, including the \n.

The data are not removed from the buffer. If no line is found, all data are returned.

source

pub fn may_recv(&self) -> Result<bool>

Returns true if the channel may still receive data.

source

pub fn output(&self) -> Result<usize>

Returns the length of outgoing data of the channel buffer.

source

pub fn prepend(&self, data: impl AsRef<[u8]>) -> Result<isize>

Copies the data in front of incoming data of the channel buffer. Returns the copied length on success or -1 if data cannot be copied.

source

pub fn remove( &self, offset: Option<isize>, length: Option<usize> ) -> Result<isize>

Removes length bytes of incoming data of the channel buffer, starting at offset. Returns number of bytes removed on success.

source

pub fn send(&self, data: impl AsRef<[u8]>) -> Result<isize>

Requires immediate send of the data. It means the data is copied at the beginning of incoming data of the channel buffer and immediately forwarded.

source

pub fn set( &self, data: impl AsRef<[u8]>, offset: Option<isize>, length: Option<usize> ) -> Result<isize>

Replaces length bytes of incoming data of the channel buffer, starting at offset, by the new data. Returns the copied length on success or -1 if data cannot be copied.

Trait Implementations§

source§

impl<'lua> Clone for Channel<'lua>

source§

fn clone(&self) -> Channel<'lua>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'lua> FromLua<'lua> for Channel<'lua>

source§

fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self>

Performs the conversion.
source§

impl<'lua> IntoLua<'lua> for Channel<'lua>

source§

fn into_lua(self, _: &'lua Lua) -> Result<Value<'lua>>

Performs the conversion.

Auto Trait Implementations§

§

impl<'lua> !RefUnwindSafe for Channel<'lua>

§

impl<'lua> !Send for Channel<'lua>

§

impl<'lua> !Sync for Channel<'lua>

§

impl<'lua> Unpin for Channel<'lua>

§

impl<'lua> !UnwindSafe for Channel<'lua>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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<'lua, T> FromLuaMulti<'lua> for Twhere T: FromLua<'lua>,

source§

fn from_lua_multi(values: MultiValue<'lua>, lua: &'lua Lua) -> Result<T, Error>

Performs the conversion. Read more
source§

fn from_lua_args( args: MultiValue<'lua>, i: usize, to: Option<&str>, lua: &'lua Lua ) -> Result<T, Error>

source§

unsafe fn from_stack_multi(nvals: i32, lua: &'lua Lua) -> Result<T, Error>

source§

unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &'lua Lua ) -> Result<T, Error>

source§

impl<T, U> Into<U> for Twhere 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<'lua, T> IntoLuaMulti<'lua> for Twhere T: IntoLua<'lua>,

source§

fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>, Error>

Performs the conversion.
source§

unsafe fn push_into_stack_multi(self, lua: &'lua Lua) -> Result<i32, Error>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.