mayuri 0.2.0

An Asynchronous WebSocket Client Library.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::io;

use super::frame::Frame;

pub struct Context {
    pub frame: Frame,
}

impl Context {
    pub const fn new(frame: Frame) -> Result<Self, io::Error> {
        Ok(Self { frame })
    }

    #[must_use]
    pub fn read_text(&self) -> String {
        String::from_utf8_lossy(&self.frame.payload_data).to_string()
    }
}