1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! PLY file deserialization.
pub
pub use *;
pub
pub
use ;
pub use PlyReader;
use Deserialize;
use crateDeserializeError;
/// Deserialize PLY data from a reader.
///
/// This is the primary entry point for deserializing complete PLY files.
/// The reader should contain the full PLY file including header.
///
/// # Example
/// ```rust
/// use serde::Deserialize;
/// use std::io::{BufReader, Cursor};
///
/// #[derive(Deserialize)]
/// struct Vertex { x: f32, y: f32, z: f32 }
///
/// #[derive(Deserialize)]
/// struct Mesh { vertex: Vec<Vertex> }
///
/// let ply_data = b"ply\nformat ascii 1.0\nelement vertex 1\nproperty float x\nproperty float y\nproperty float z\nend_header\n1.0 2.0 3.0\n";
/// let reader = BufReader::new(Cursor::new(ply_data));
/// let mesh: Mesh = serde_ply::from_reader(reader)?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
/// Deserialize PLY data from bytes.
///
/// Convenience function for parsing PLY data from a byte slice.
/// Works with both ASCII and binary format PLY files.
/// Deserialize PLY data from a string.
///
/// Convenience function for parsing PLY data from strings.
/// Only works for ASCII format PLY files since binary data is not valid UTF-8.
///
/// # Example
/// ```rust
/// use serde::Deserialize;
///
/// #[derive(Deserialize)]
/// struct Point { x: f32, y: f32 }
///
/// #[derive(Deserialize)]
/// struct Points { vertex: Vec<Point> }
///
/// let ply = "ply\nformat ascii 1.0\nelement vertex 2\nproperty float x\nproperty float y\nend_header\n0.0 0.0\n1.0 1.0\n";
/// let points: Points = serde_ply::from_str(ply)?;
/// assert_eq!(points.vertex.len(), 2);
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```