pub struct Session { /* private fields */ }
Expand description
Session manager.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(metainfo: Metainfo, own_id: [u8; 20]) -> Session
pub fn new(metainfo: Metainfo, own_id: [u8; 20]) -> Session
Create new instance managing peer-to-peer connection. Currently most settings, are set as constatns.
§Example
use rdest::{Metainfo, Session};
use std::path::PathBuf;
let path = PathBuf::from("ubuntu-20.04.2.0-desktop-amd64.iso.torrent");
let torrent_file = Metainfo::from_file(path.as_path()).unwrap();
let peer_id = b"AAAAABBBBBCCCCCDDDDD";
let mut session = Session::new(torrent_file, *peer_id);
Sourcepub async fn run(&mut self)
pub async fn run(&mut self)
Run Session that will try connect to tracker, get list of available peers, and establish connection with them
§Example
use rdest::{Metainfo, Session};
use std::path::Path;
let path = Path::new("ubuntu-20.04.2.0-desktop-amd64.iso.torrent");
let torrent_file = Metainfo::from_file(path).unwrap();
let peer_id = b"AAAAABBBBBCCCCCDDDDD";
let mut session = Session::new(torrent_file, *peer_id);
session.run().await;
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
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