New week, new Rust! What are you folks up to?
I am working on a portable Web API inspired by the glTF 2.0 3D graphics format to be able to create, manage and delete glTF resources (meshes, textures, scene nodes...) in real-time.
In order for the API to follow the specification of JSON:API (https://jsonapi.org/), I built a specific `jsonapi` crate that makes it easy to create JSON:API-compliant resources and endpoints:
/// A view into a buffer generally representing a subset of the buffer.
#[derive(Debug, Clone, Default, Serialize, ToSchema, ToResourceObject)]
pub struct BufferView {
pub id: Uuid<BufferView>,
/// The index of the buffer.
#[jsonapi(relationship(to = crate::buffer::Buffer, as = Buffer))]
pub buffer: Uuid<Buffer>,
/// The offset into the buffer in bytes.
#[schema(default = 0)]
pub byte_offset: u32,
/// The length of the buffer view in bytes.
#[schema(minimum = 1)]
pub byte_length: u32,
/// The stride, in bytes, between vertex attributes. When this is not defined, data is tightly packed. When two or
/// more accessors use the same buffer view, this field **MUST** be defined.
#[schema(minimum = 4, maximum = 252, example = 4)]
pub byte_stride: Option<u32>,
/// The hint representing the intended GPU buffer type to use with this buffer view.
pub target: Option<BufferViewTarget>,
/// The user-defined name of this object. This is not necessarily unique, e.g., an accessor and a buffer could have
/// the same name, or two accessors could even have the same name.
#[schema(example = "my-buffer-view")]
pub name: Option<String>,
}
#[utoipa::path(
tag = "Buffer",
responses(BufferViewResourceResponse),
params(BufferViewResourceQueryParameters, Pagination)
)]
#[get("/buffer-view/")]
async fn list_buffer_views(
req: HttpRequest,
db: web::Data<Database>,
pagination: web::Query<Pagination>,
query: web::Query<BufferViewResourceQueryParameters>,
) -> impl Responder {
ResponseBuilder::<BufferViewResourceObject>::new(req.uri().clone())
.pagination(pagination.into_inner())
.relationship_resolver(BufferResolver::new(db.clone().into_inner()))
.query_parameters(query.into_inner())
.select::<BufferViewModel>(db.into_inner())
.build()
.await
}
The API also leverages the utoipa crate (GitHub - juhaku/utoipa: Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust) in order to automatically generate and expose a valid OpenAPI definition.
Making it possible - among other things - for LLMs such as ChatGPT to render and edit 3D scenes in real-time.
Greetings!
Just got started with Rust, a few weeks ago. I enjoy the learning curve, and since I am using it for developing a new indie video game (complex adaptive system based world simulation with millions of objects/subjects), I learn Rust backwards from working with Bevy. I decided for Rust/Bevy due to ECS and the massive scale/parallelism possible (and necessary for my system simulation). Great inspiration for what is possible is the open sourced Veloren game, such a great inspiration!
I love the Rust language community & resources that make getting started in Rust not as tough as it could be. Coming from a couple of other imperative, declarative and functional languages, I think I already have a good understanding of 75% of the core language. But reading/writing Macros....boy, a whole other story
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.