pub struct WinINetRequest<'a>(/* private fields */);Expand description
A WinINet “request”
Create it with WinINetConnection::request
Implementations§
Source§impl WinINetRequest<'_>
impl WinINetRequest<'_>
Sourcepub fn open(&self) -> Result<(), Error>
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}Sourcepub fn send(&self) -> Result<(), Error>
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}Sourcepub fn recv(&self) -> Result<(), Error>
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<'_>
impl Drop for WinINetRequest<'_>
Source§impl Future for WinINetRequest<'_>
impl Future for WinINetRequest<'_>
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> 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
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more