Draft: PREVIEW: audio: take advantage of package name to avoid type and const name redundancy
This is a preview for how code would look like with gstreamer-rs#374 (closed). Only plugins under audio
are affected in this preview. This is because I only changed gst_base
& gst_audio
so far. See this branch.
This is based on gir
changes from this branch:
-
A "removable prefix" is determined based on each namespace specificities: if the first symbol prefix (e.g.
gst
, from the gir file namespace attributec:symbol-prefixes
) matches the first part of the crate name (e.g.gst_audio
), then all functions starting withaudio_
, all types starting withAudio
and all constants starting withAUDIO_
will get their prefix removed... -
... unless
Gir.toml
instructs otherwise (just to show how this could be fine-tuned):-
Disabling for all types in a namespace
[[object]] name = "GstApp.*" removable_prefix = "disabled"
-
Disabling for a specific type only
[[object]] name = "GstBase.BaseSink" removable_prefix = "disabled"
-
Disabling for all constants
[[object]] name = "GstGL.*" [..] [[object.constant]] pattern = "*" removable_prefix = "disabled"
-
Disabling for a specific constant only
[[object]] name = "GstGL.*" [..] [[object.constant]] name = "GL_API_GLES1_NAME" removable_prefix = "disabled"
-
Forcing for all types in a namespace
[[object]] name = "GstRtspServer.*" removable_prefix = "RTSP"
-
and so on...
-
-
I also removed the prefix from generated and manual source filenames. This leads to shorter paths and
use
clauses. E.g.:use gst_base::subclass::transform::GenerateOutputSuccess;
See this
FIXME
for an unrelated proposal about this particularuse
clause, and this otherFIXME
for a similar proposal. -
However, I kept the
trait
s prefix to avoid conflicts when used with aprelude::*
clause. So we still haveBaseSinkExt
andAudioBaseSinkExt
for instance.