Skip to main content

Stream

Struct Stream 

Source
pub struct Stream { /* private fields */ }

Implementations§

Source§

impl Stream

Source

pub fn is_keep_alive(&self, keep_alive: bool) -> bool

Checks if the connection should be kept alive.

This method evaluates whether the connection should remain open based on the closed state and the keep_alive parameter.

§Arguments
  • bool - Whether keep-alive is enabled for the request.
§Returns
  • bool - True if the connection should be kept alive, otherwise false.
Source

pub unsafe fn free(&mut self)

Free the context.

§Safety
  • The address is guaranteed to be a valid Self instance that was previously converted from a reference and is managed by the runtime.
Source

pub async fn try_get_http_request(&mut self) -> Result<Request, RequestError>

Parses an HTTP request from a TCP stream.

Wraps the stream in a buffered reader and delegates to http_from_reader. If the timeout is DEFAULT_LOW_SECURITY_READ_TIMEOUT_MS, no timeout is applied.

§Returns
  • Result<Request, RequestError> - The parsed request or an error.
Source

pub async fn try_get_websocket_request( &mut self, ) -> Result<RequestBody, RequestError>

Parses a WebSocket request from a TCP stream.

Wraps the stream in a buffered reader and delegates to ws_from_reader. If the timeout is DEFAULT_LOW_SECURITY_READ_TIMEOUT_MS, no timeout is applied.

§Returns
  • Result<Request, RequestError>: The parsed WebSocket request or an error.
Source

pub async fn try_send<D>(&mut self, data: D) -> Result<(), ResponseError>
where D: AsRef<[u8]>,

Sends data over the stream.

§Arguments
  • AsRef<[u8]> - The data to send (must implement AsRef<u8>).
§Returns
  • Result<(), ResponseError> - Result indicating success or failure.
Source

pub async fn send<D>(&mut self, data: D)
where D: AsRef<[u8]>,

Sends data over the stream.

§Arguments
  • AsRef<[u8]> - The data to send (must implement AsRef<u8>).
§Panics

Panics if the write operation fails.

Source

pub async fn try_send_list<I, D>( &mut self, data_iter: I, ) -> Result<(), ResponseError>
where I: IntoIterator<Item = D>, D: AsRef<[u8]>,

Sends multiple data.

§Arguments
  • IntoIterator<Item = AsRef<[u8]>> - The data list to send.
§Returns
  • Result<(), ResponseError> - Result indicating success or failure.
Source

pub async fn send_list<I, D>(&mut self, data_iter: I)
where I: IntoIterator<Item = D>, D: AsRef<[u8]>,

Sends multiple data.

§Arguments
  • IntoIterator<Item = AsRef<[u8]>> - The data list to send.
§Panics

Panics if any write operation fails.

Source

pub async fn try_flush(&mut self) -> Result<(), ResponseError>

Flushes all buffered data to the stream.

§Returns
  • Result<(), ResponseError> - Result indicating success or failure.
Source

pub async fn flush(&mut self)

Flushes all buffered data to the stream.

§Panics

Panics if the flush operation fails.

Source§

impl Stream

Source

pub fn get_stream(&self) -> &TcpStream

Source

pub fn get_request_config(&self) -> &RequestConfig

Source

pub fn get_closed(&self) -> bool

Source

pub fn set_closed(&mut self, val: bool) -> &mut Self

Source§

impl Stream

Source

pub fn new( stream: TcpStream, request_config: RequestConfig, closed: bool, ) -> Self

Trait Implementations§

Source§

impl AsMut<Stream> for Stream

Implementation of AsMut trait for Stream.

Source§

fn as_mut(&mut self) -> &mut Self

Converts &mut Stream to &mut Stream via memory address conversion.

§Returns
  • &mut Stream - A mutable reference to the Stream instance.
Source§

impl AsRef<Stream> for Stream

Implementation of AsRef trait for Stream.

Source§

fn as_ref(&self) -> &Self

Converts &Stream to &Stream via memory address conversion.

§Returns
  • &Stream - A reference to the Stream instance.
Source§

impl Debug for Stream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Stream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Stream> for usize

Implementation of From trait for converting &Stream into usize address.

Source§

fn from(stream: &Stream) -> Self

Converts a reference to Stream into its memory address.

§Arguments
  • &Stream - The reference to the Stream instance.
§Returns
  • usize - The memory address of the Stream instance.
Source§

impl From<&mut Stream> for usize

Implementation of From trait for converting &mut Stream into usize address.

Source§

fn from(stream: &mut Stream) -> Self

Converts a mutable reference to Stream into its memory address.

§Arguments
  • &mut Stream - The mutable reference to the Stream instance.
§Returns
  • usize - The memory address of the Stream instance.
Source§

impl From<usize> for &'static Stream

Implementation of From trait for converting usize address into &Stream.

Source§

fn from(address: usize) -> &'static Stream

Converts a memory address into a reference to Stream.

§Arguments
  • usize - The memory address of the Stream instance.
§Returns
  • &'static Stream - A reference to the Stream at the given address.
§Safety
  • The address is guaranteed to be a valid Stream instance that was previously converted from a reference and is managed by the runtime.
Source§

impl<'a> From<usize> for &'a mut Stream

Implementation of From trait for converting usize address into &mut Stream.

Source§

fn from(address: usize) -> &'a mut Stream

Converts a memory address into a mutable reference to Stream.

§Arguments
  • usize - The memory address of the Stream instance.
§Returns
  • &mut Stream - A mutable reference to the Stream at the given address.
§Safety
  • The address is guaranteed to be a valid Stream instance that was previously converted from a reference and is managed by the runtime.
Source§

impl Lifetime for Stream

Implementation of Lifetime trait for Stream.

Source§

unsafe fn leak(&self) -> &'static Self

Converts a reference to the stream into a 'static reference.

§Returns
  • &'static Self: A reference to the stream with a 'static lifetime.
§Safety
  • The address is guaranteed to be a valid Self instance that was previously converted from a reference and is managed by the runtime.
Source§

unsafe fn leak_mut(&self) -> &'static mut Self

Converts a reference to the stream into a 'static mutable reference.

§Returns
  • &'static mut Self: A mutable reference to the stream with a 'static lifetime.
§Safety
  • The address is guaranteed to be a valid Self instance that was previously converted from a reference and is managed by the runtime.

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySync for T
where T: Any + Sync,