Changed name to mcpi_api added some documentation
This commit is contained in:
parent
05efd7143c
commit
aa35a0b617
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "mcpi"
|
||||
name = "mcpi_api"
|
||||
version = "0.1.0"
|
||||
authors = ["blackfur <64478051+theblackfurguy@users.noreply.github.com>"]
|
||||
edition = "2018"
|
||||
|
|
16
src/lib.rs
16
src/lib.rs
|
@ -1,3 +1,5 @@
|
|||
//! # MCPI API
|
||||
//! `mcpi_api` is a warpper for the Minecraft Pi Edition API handling parsing and other aspects for you.
|
||||
use std::io::prelude::*;
|
||||
use std::net::TcpStream;
|
||||
use std::io::BufReader;
|
||||
|
@ -11,6 +13,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
///Struct containing functions and a Connection struct.
|
||||
pub struct Minecraft {
|
||||
conn:Connection
|
||||
}
|
||||
|
@ -19,10 +22,12 @@ struct Connection {
|
|||
stream:TcpStream
|
||||
}
|
||||
|
||||
///Struct containing functions and a Connection struct.
|
||||
pub struct Player<'a> {
|
||||
conn:&'a mut Connection
|
||||
}
|
||||
|
||||
///Struct used to specify tile positions.
|
||||
#[derive(Debug)]
|
||||
pub struct TileVec3 {
|
||||
pub x:i32,
|
||||
|
@ -30,6 +35,7 @@ pub struct TileVec3 {
|
|||
pub z:i32
|
||||
}
|
||||
|
||||
///Struct used to specify entity positions.
|
||||
#[derive(Debug)]
|
||||
pub struct Vec3 {
|
||||
pub x:f32,
|
||||
|
@ -187,6 +193,16 @@ impl Player<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
///Function to create a Minecraft struct.
|
||||
/// Takes a IP adress and a port as arguments.
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use mcpi_api::create;
|
||||
/// let mut mc = create("localhost:4711");
|
||||
/// mc.post_to_chat("Hello World!")
|
||||
/// ```
|
||||
/// # Panics
|
||||
/// This function panics if binding to the adress fails.
|
||||
pub fn create(adress:&str) -> Minecraft {
|
||||
let stream = TcpStream::connect(adress);
|
||||
match stream {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use mcpi::{create, TileVec3};
|
||||
use mcpi_api::{create, TileVec3};
|
||||
|
||||
#[test]
|
||||
fn main() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use mcpi::{Vec3, create, TileVec3};
|
||||
use mcpi_api::{Vec3, create, TileVec3};
|
||||
|
||||
#[test]
|
||||
fn main() {
|
||||
|
|
Loading…
Reference in a new issue