pub struct Response { /* private fields */ }Implementations§
Source§impl Response
impl Response
pub fn new() -> Response
pub fn extend_buffer(&mut self, buffer: &mut Buffer) -> Result<bool, HlsError>
pub fn extend_frame( &mut self, frame: &H2FrameRBuf<'_>, hpack_coding: &mut HackDecode, ) -> Result<bool, HlsError>
pub fn push_raw(&mut self, raw: Vec<u8>)
pub fn header(&self) -> &Header
pub fn header_mut(&mut self) -> &mut Header
pub fn raw_body(&self) -> &[u8] ⓘ
pub fn raw_string(&self) -> String
pub fn clear_raw(&mut self)
pub fn decode_body(&mut self) -> Result<&mut Body, HlsError>
pub fn json(self) -> Result<JsonValue, HlsError>
Sourcepub fn text(self) -> Result<String, HlsError>
pub fn text(self) -> Result<String, HlsError>
Examples found in repository?
examples/m3u8_down.rs (line 58)
55 fn get_key(&mut self) -> Result<(), HlsError> {
56 println!("key url: {}", self.key_url);
57 self.req.set_url(self.key_url.as_str())?;
58 let key = self.req.send_check(Method::GET)?.text()?;
59 println!("key: {}; sequence: {}", key, self.sequence);
60 self.cipher.set_secret_key(key.into_bytes(), Some(self.sequence.to_be_bytes().to_vec()));
61 Ok(())
62 }
63
64 fn download(&mut self) -> Result<(), HlsError> {
65 self.req.set_url(self.index_url.as_str())?;
66 let body = self.req.send_check(Method::GET)?.text()?;
67 // println!("{}", body);
68 for line in body.split("\n") {
69 if line.starts_with("#EXT-X-MEDIA-SEQUENCE:") {
70 self.sequence = line.trim().replace("#EXT-X-MEDIA-SEQUENCE:", "").parse()?;
71 continue;
72 }
73 if line.starts_with("#EXT-X-KEY") {
74 let pos = line.find("URI=\"");
75 if let Some(pos) = pos {
76 self.key_url = line[pos + 4..].trim().replace("\"", "");
77 }
78 if line.contains("=AES-128,") {
79 self.cipher = Cipher::aes_128_cbc();
80 }
81 continue;
82 }
83 if line.starts_with("http") {
84 self.ts_urls.push(line.trim().to_string());
85 }
86 }
87 let mut timeout = Timeout::new();
88 timeout.set_read(5000);
89 timeout.set_write(5000);
90 timeout.set_connect(5000);
91 timeout.set_handle(30000);
92 timeout.set_handle_times(10);
93 self.req.set_timeout(timeout);
94 if !self.key_url.is_empty() { self.get_key()?; }
95 self.down_ts()?;
96 Ok(())
97 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more