我有一个用c ++构建的smtp客户端,我可以将电子邮件发送到我的测试mailtrap帐户.标题已发送,电子邮件即将到达.
我的问题是,从/到指示的字段是空的 - 如屏幕截图所示
我正在发送标题
write_command("MAIL FROM: <foo@bar.de>");
write_command("RCPT TO: <foo@bar.de>");
Run Code Online (Sandbox Code Playgroud)
我用我的Smtp客户端的完整代码做了一个要点
https://gist.github.com/anonymous/7bb13de7f044bcb5d07d0e6a9d991ea9
我是从我的main()功能中调用它的
同
Smtp smtp_client = Smtp();
smtp_client.new_connection("smtp.mailtrap.io", 25);
smtp_client.auth_login("username", "password");
smtp_client.sendmail();
smtp_client.close_connection();
Run Code Online (Sandbox Code Playgroud)
谢谢你的表情
我希望此函数返回错误结果:
fn get_result() -> Result<String, std::io::Error> {
// Ok(String::from("foo")) <- works fine
Result::Err(String::from("foo"))
}
Run Code Online (Sandbox Code Playgroud)
错误信息
error[E0308]: mismatched types
--> src/main.rs:3:17
|
3 | Result::Err(String::from("foo"))
| ^^^^^^^^^^^^^^^^^^^ expected struct `std::io::Error`, found struct `std::string::String`
|
= note: expected type `std::io::Error`
found type `std::string::String`
Run Code Online (Sandbox Code Playgroud)
我很困惑如何在使用预期的结构时打印出错误消息.
我几乎不知道如何描述这种行为,所以这可能是我无法自己找到答案的原因 - 我根本就不知道如何命名这个问题.所以,如果标题是误导性的,或者问题在某种程度上是错误的,请耐心等待,但是这里来了
我有一个类方法,我打开一个文件并获取文件名:
OPENFILENAME GuiUtils::ChooseFileDialog(HWND hwnd)
{
OPENFILENAME ofn;
char szFile[260];
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = (LPWSTR)szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrFilter = TEXT("Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0");
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
HANDLE hf;
// Display the Open dialog box.
if (GetOpenFileName(&ofn) == TRUE)
{
hf = CreateFile(ofn.lpstrFile,
GENERIC_READ,
0,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)NULL);
}
return ofn;
}
Run Code Online (Sandbox Code Playgroud)
当我看到 …
我找不到可以做到这一点的东西。到目前为止,我所拥有的仅适用于空白:
pub fn minify(&self) {
println!("Minify task started ... ");
let mut string_iter = self.mystring.split_whitespace();
for strings in string_iter {
println!("{}", strings);
}
}
Run Code Online (Sandbox Code Playgroud)
mystring 是这样的:
let mystring = "p {
text-align: center;
color: red;
} ";
Run Code Online (Sandbox Code Playgroud)