WinINetRequest

Struct WinINetRequest 

Source
pub struct WinINetRequest<'a>(/* private fields */);
Expand description

A WinINet “request”

Create it with WinINetConnection::request

Implementations§

Source§

impl WinINetRequest<'_>

Source

pub fn open(&self) -> Result<(), Error>

Examples found in repository?
examples/async.rs (line 51)
20fn work() -> std::io::Result<()> {
21  unsafe {
22    barrier = Some(Barrier::new(2));
23  }
24
25    #[cfg(feature = "unicode")]
26    let (agent, host, method, path) = (
27      U16CString::from_str("Hello, world!").unwrap(),
28      U16CString::from_str("drak.li").unwrap(),
29      U16CString::from_str("GET").unwrap(),
30      U16CString::from_str("/").unwrap()
31    );
32    #[cfg(not(feature = "unicode"))]
33    let (agent, host, method, path) = (
34      CString::new("Hello, world!").unwrap(),
35      CString::new("drak.li").unwrap(),
36      CString::new("GET").unwrap(),
37      CString::new("/").unwrap()
38    );
39
40    let mut agent = WinINet::new(
41      &agent,
42      InternetOpenType::Preconfig,
43      None,
44      None,
45    )?;
46    agent.set_callback(Some(callback));
47    let c = agent.connect(&host, 80, None, None)?;
48    let r = c.request(&method, &path, false)?;
49    
50    println!("open...");
51    if let Err(e) = r.open() {
52      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
53        return Err(e);
54      }
55      println!("wait");
56      unsafe {barrier.as_ref()}.unwrap().wait();
57    }
58
59    println!("send...");
60    unsafe {
61      barrier = Some(Barrier::new(2));
62    }
63    if let Err(e) = r.send() {
64      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
65        return Err(e);
66      }
67      println!("wait2");
68      unsafe {barrier.as_ref()}.unwrap().wait();
69    }
70    println!("recv...");
71    unsafe {
72      barrier = Some(Barrier::new(2));
73    }
74    if let Err(e) = r.recv() {
75      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
76        return Err(e);
77      }
78      println!("wait3");
79      unsafe {barrier.as_ref()}.unwrap().wait();
80
81    }
82    Ok(())
83}
Source

pub fn send(&self) -> Result<(), Error>

Examples found in repository?
examples/async.rs (line 63)
20fn work() -> std::io::Result<()> {
21  unsafe {
22    barrier = Some(Barrier::new(2));
23  }
24
25    #[cfg(feature = "unicode")]
26    let (agent, host, method, path) = (
27      U16CString::from_str("Hello, world!").unwrap(),
28      U16CString::from_str("drak.li").unwrap(),
29      U16CString::from_str("GET").unwrap(),
30      U16CString::from_str("/").unwrap()
31    );
32    #[cfg(not(feature = "unicode"))]
33    let (agent, host, method, path) = (
34      CString::new("Hello, world!").unwrap(),
35      CString::new("drak.li").unwrap(),
36      CString::new("GET").unwrap(),
37      CString::new("/").unwrap()
38    );
39
40    let mut agent = WinINet::new(
41      &agent,
42      InternetOpenType::Preconfig,
43      None,
44      None,
45    )?;
46    agent.set_callback(Some(callback));
47    let c = agent.connect(&host, 80, None, None)?;
48    let r = c.request(&method, &path, false)?;
49    
50    println!("open...");
51    if let Err(e) = r.open() {
52      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
53        return Err(e);
54      }
55      println!("wait");
56      unsafe {barrier.as_ref()}.unwrap().wait();
57    }
58
59    println!("send...");
60    unsafe {
61      barrier = Some(Barrier::new(2));
62    }
63    if let Err(e) = r.send() {
64      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
65        return Err(e);
66      }
67      println!("wait2");
68      unsafe {barrier.as_ref()}.unwrap().wait();
69    }
70    println!("recv...");
71    unsafe {
72      barrier = Some(Barrier::new(2));
73    }
74    if let Err(e) = r.recv() {
75      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
76        return Err(e);
77      }
78      println!("wait3");
79      unsafe {barrier.as_ref()}.unwrap().wait();
80
81    }
82    Ok(())
83}
Source

pub fn recv(&self) -> Result<(), Error>

Examples found in repository?
examples/async.rs (line 74)
20fn work() -> std::io::Result<()> {
21  unsafe {
22    barrier = Some(Barrier::new(2));
23  }
24
25    #[cfg(feature = "unicode")]
26    let (agent, host, method, path) = (
27      U16CString::from_str("Hello, world!").unwrap(),
28      U16CString::from_str("drak.li").unwrap(),
29      U16CString::from_str("GET").unwrap(),
30      U16CString::from_str("/").unwrap()
31    );
32    #[cfg(not(feature = "unicode"))]
33    let (agent, host, method, path) = (
34      CString::new("Hello, world!").unwrap(),
35      CString::new("drak.li").unwrap(),
36      CString::new("GET").unwrap(),
37      CString::new("/").unwrap()
38    );
39
40    let mut agent = WinINet::new(
41      &agent,
42      InternetOpenType::Preconfig,
43      None,
44      None,
45    )?;
46    agent.set_callback(Some(callback));
47    let c = agent.connect(&host, 80, None, None)?;
48    let r = c.request(&method, &path, false)?;
49    
50    println!("open...");
51    if let Err(e) = r.open() {
52      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
53        return Err(e);
54      }
55      println!("wait");
56      unsafe {barrier.as_ref()}.unwrap().wait();
57    }
58
59    println!("send...");
60    unsafe {
61      barrier = Some(Barrier::new(2));
62    }
63    if let Err(e) = r.send() {
64      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
65        return Err(e);
66      }
67      println!("wait2");
68      unsafe {barrier.as_ref()}.unwrap().wait();
69    }
70    println!("recv...");
71    unsafe {
72      barrier = Some(Barrier::new(2));
73    }
74    if let Err(e) = r.recv() {
75      if e.raw_os_error() != Some(win_inet::ERROR_IO_PENDING) {
76        return Err(e);
77      }
78      println!("wait3");
79      unsafe {barrier.as_ref()}.unwrap().wait();
80
81    }
82    Ok(())
83}

Trait Implementations§

Source§

impl Drop for WinINetRequest<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Future for WinINetRequest<'_>

Source§

type Output = Result<(), Error>

The type of value produced on completion.
Source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempts to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for WinINetRequest<'a>

§

impl<'a> RefUnwindSafe for WinINetRequest<'a>

§

impl<'a> !Send for WinINetRequest<'a>

§

impl<'a> !Sync for WinINetRequest<'a>

§

impl<'a> Unpin for WinINetRequest<'a>

§

impl<'a> UnwindSafe for WinINetRequest<'a>

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<F> IntoFuture for F
where F: Future,

Source§

type Output = <F as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = F

Which kind of future are we turning this into?
Source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. 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.