These are chat archives for rust-lang/rust

13th
Jul 2017
Arthur
@Biacode
Jul 13 2017 11:00
Hey, any good/known crate for sending email?
Max Frai
@max-frai
Jul 13 2017 11:32
@Biacode Have you tried to use a search? :) https://docs.rs/lettre/0.6.2/lettre/
Arthur
@Biacode
Jul 13 2017 11:33
ofc tried, but there is couple of them. I thought maybe some body already have tested solution
Berardino
@berab78_twitter
Jul 13 2017 16:42
I am trying to compile this simple snippet, but getting : the trait std::ops::Carrier is not implemented for ()
use std::io::{self, BufReader};
use std::io::prelude::*;
use std::fs::File;


pub fn main() {
    let f = File::open("bunny.obj")?;
    let b = BufReader::new(f);
}
Ilya Bogdanov
@vitvakatu
Jul 13 2017 16:44
What version of rust are you using?
Berardino
@berab78_twitter
Jul 13 2017 16:45
rustc 1.18.0 (03fc9d622 2017-06-06)
Denis Lisov
@tanriol
Jul 13 2017 16:45
@berab78_twitter The current Rust versions don't support the ? operator in main
It can be used only in functions that return a Result
Berardino
@berab78_twitter
Jul 13 2017 16:46
I am pretty new at rust, I took that sample from the documentation https://doc.rust-lang.org/std/io/trait.BufRead.html
@tanriol I see, not in main, so I simply need to move that code into a function, thank you
Denis Lisov
@tanriol
Jul 13 2017 16:48
If you try running the example with the Run button, you'll see that it's wrapped in a fn foo() -> io::Result<()> { ... }
Berardino
@berab78_twitter
Jul 13 2017 16:49
right, how did I miss that :) thank you
Arthur
@Biacode
Jul 13 2017 18:23
How to read file from user home directory? like $HOME etc...
Arthur
@Biacode
Jul 13 2017 18:25
The only ways is read env?
thanks
stevensonmt
@stevensonmt
Jul 13 2017 18:25
I don't know if that is the only way though.
Denis Lisov
@tanriol
Jul 13 2017 18:26
There were some crates for application directories...
Arthur
@Biacode
Jul 13 2017 18:27
For example?
Denis Lisov
@tanriol
Jul 13 2017 18:33
What about app_dirs? No experience, but looks interesting...
the envy and dotenv crates look promising but I also have no experience with these.
Arthur
@Biacode
Jul 13 2017 18:34
nice, thank you all
Denis Lisov
@tanriol
Jul 13 2017 18:35
@stevensonmt My point is that quite often you want actually not to "read a file from the home dir", but to "read my app's config / cache / data / etc." and it's a good idea to follow the platform conventions on their placement...
stevensonmt
@stevensonmt
Jul 13 2017 18:37
ah, I may have misunderstood the question. I'm a fair noob to rust myself so I may do that quite often.
Arthur
@Biacode
Jul 13 2017 18:37
Hmm, what If I need to read user specified configurations?
I want to write some sort of service, which will configure himself and start sending emails about system missconfiguration
Denis Lisov
@tanriol
Jul 13 2017 18:42
Well, that depends on the way your user specifies them :-) do they write a file path?
Arthur
@Biacode
Jul 13 2017 18:53
Well, I think It can be like this
scan some predefined directories like
home, home/.app_name. /etc/app_name etc...
and configure service based on first occurrence of config file
Denis Lisov
@tanriol
Jul 13 2017 18:56
What about just using app_dirs with UserConfig and, if not found, SharedConfig locations?
Arthur
@Biacode
Jul 13 2017 18:57
yeah, I was thinking about it.
What about SharedConfig? it is some kind of crate? or?
Denis Lisov
@tanriol
Jul 13 2017 18:58
These two are constants from app_dirs
Arthur
@Biacode
Jul 13 2017 19:00
Nice, thanks!