Added base for Request future

This commit is contained in:
2020-06-28 23:39:17 +02:00
parent 4e7c0bf2be
commit bda6fe673e
2 changed files with 52 additions and 19 deletions

29
.idea/workspace.xml generated
View File

@@ -23,12 +23,8 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="bd356b53-8877-4762-bc50-8d6780ab07cb" name="Default Changelist" comment=""> <list default="true" id="bd356b53-8877-4762-bc50-8d6780ab07cb" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/gopher.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/configuration.rs" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/src/gopher.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/gopher.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/traits/Document.rs" beforeDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -59,7 +55,7 @@
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" /> <property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" />
<property name="org.rust.hideDetachedFileNotifications/home/jali/Projects/gopherbridge/src/gopherrequest.rs" value="true" /> <property name="org.rust.hideDetachedFileNotifications/home/jali/Projects/gopherbridge/src/gopherrequest.rs" value="true" />
<property name="settings.editor.selected.configurable" value="editing.templates" /> <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component> </component>
<component name="RunAnythingCache"> <component name="RunAnythingCache">
<option name="myCommands"> <option name="myCommands">
@@ -126,6 +122,7 @@
</entry> </entry>
</map> </map>
</option> </option>
<option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="1759" y="376" width="734" height="634" key="#Inspections" timestamp="1592162631281"> <state x="1759" y="376" width="734" height="634" key="#Inspections" timestamp="1592162631281">
@@ -160,26 +157,26 @@
<screen x="0" y="0" width="3440" height="1408" /> <screen x="0" y="0" width="3440" height="1408" />
</state> </state>
<state x="1517" y="461" width="426" height="481" key="FileChooserDialogImpl/0.0.3440.1408@0.0.3440.1408" timestamp="1592143269262" /> <state x="1517" y="461" width="426" height="481" key="FileChooserDialogImpl/0.0.3440.1408@0.0.3440.1408" timestamp="1592143269262" />
<state width="1897" height="253" key="GridCell.Tab.0.bottom" timestamp="1592163709599"> <state width="1897" height="253" key="GridCell.Tab.0.bottom" timestamp="1592172101033">
<screen x="0" y="0" width="3440" height="1408" /> <screen x="0" y="0" width="3440" height="1408" />
</state> </state>
<state width="1897" height="253" key="GridCell.Tab.0.bottom/0.0.3440.1408@0.0.3440.1408" timestamp="1592163709599" /> <state width="1897" height="253" key="GridCell.Tab.0.bottom/0.0.3440.1408@0.0.3440.1408" timestamp="1592172101033" />
<state width="1897" height="253" key="GridCell.Tab.0.center" timestamp="1592163709599"> <state width="1897" height="253" key="GridCell.Tab.0.center" timestamp="1592172101033">
<screen x="0" y="0" width="3440" height="1408" /> <screen x="0" y="0" width="3440" height="1408" />
</state> </state>
<state width="1897" height="253" key="GridCell.Tab.0.center/0.0.3440.1408@0.0.3440.1408" timestamp="1592163709599" /> <state width="1897" height="253" key="GridCell.Tab.0.center/0.0.3440.1408@0.0.3440.1408" timestamp="1592172101033" />
<state width="1897" height="253" key="GridCell.Tab.0.left" timestamp="1592163709599"> <state width="1897" height="253" key="GridCell.Tab.0.left" timestamp="1592172101033">
<screen x="0" y="0" width="3440" height="1408" /> <screen x="0" y="0" width="3440" height="1408" />
</state> </state>
<state width="1897" height="253" key="GridCell.Tab.0.left/0.0.3440.1408@0.0.3440.1408" timestamp="1592163709599" /> <state width="1897" height="253" key="GridCell.Tab.0.left/0.0.3440.1408@0.0.3440.1408" timestamp="1592172101033" />
<state width="1897" height="253" key="GridCell.Tab.0.right" timestamp="1592163709599"> <state width="1897" height="253" key="GridCell.Tab.0.right" timestamp="1592172101033">
<screen x="0" y="0" width="3440" height="1408" /> <screen x="0" y="0" width="3440" height="1408" />
</state> </state>
<state width="1897" height="253" key="GridCell.Tab.0.right/0.0.3440.1408@0.0.3440.1408" timestamp="1592163709599" /> <state width="1897" height="253" key="GridCell.Tab.0.right/0.0.3440.1408@0.0.3440.1408" timestamp="1592172101033" />
<state x="1431" y="632" key="SettingsEditor" timestamp="1592171165276"> <state x="1323" y="270" key="SettingsEditor" timestamp="1593365092849">
<screen x="0" y="0" width="3440" height="1408" /> <screen x="0" y="0" width="3440" height="1408" />
</state> </state>
<state x="1431" y="632" key="SettingsEditor/0.0.3440.1408@0.0.3440.1408" timestamp="1592171165276" /> <state x="1323" y="270" key="SettingsEditor/0.0.3440.1408@0.0.3440.1408" timestamp="1593365092849" />
<state width="498" height="445" key="SwitcherDM" timestamp="1592151399794"> <state width="498" height="445" key="SwitcherDM" timestamp="1592151399794">
<screen x="0" y="0" width="3440" height="1408" /> <screen x="0" y="0" width="3440" height="1408" />
</state> </state>

View File

@@ -4,8 +4,32 @@
//! Version: 1.0.20166.1 //! Version: 1.0.20166.1
//! Created By: Jali <jali@orca-central.de> //! Created By: Jali <jali@orca-central.de>
use std::future::Future;
use std::io;
use std::pin::Pin;
use tokio::net::TcpStream; use tokio::net::TcpStream;
use tokio::io; use tokio::prelude::{AsyncRead, AsyncWrite};
/**
* # Description
*
* A future that asynchronously reads requests from the reader and copies the
* contents of a file back to the writer.
*
* This struct is generally created by calling [`request`][request]. Please
* the the documentation of `request()` for more details.
*/
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Request<'a, R: ?Sized, W: ?Sized> {
reader: &'a mut R,
read_done: bool,
writer: &'a mut W,
pos: usize,
cap: usize,
amt: u64,
buf: Box<[u8]>
}
/** /**
* # Description * # Description
@@ -24,6 +48,18 @@ use tokio::io;
* let amount = gopher::request(reader, writer); * let amount = gopher::request(reader, writer);
* ``` * ```
**/ **/
pub fn request(reader: io::ReadHalf<TcpStream>, writer: io::WriteHalf<TcpStream>) -> int32 { pub fn request<'a, R, W>(reader: &'a mut R, writer: &'a mut W) -> Request<'a, R, W>
where
R: AsyncRead + Unpin + ?Sized,
W: AsyncWrite + Unpin + ?Sized
{
Request {
reader,
read_done: false,
writer,
amt: 0,
pos: 0,
cap: 0,
buf: Box::new(*[0; 2048]),
}
} }