Documentation ¶
Overview ¶
Package hyphae manages hypha storage and hypha types.
Index ¶
- func AreFreeNames(hyphaNames ...string) (firstFailure string, ok bool)
- func Count() int
- func DeleteHypha(h ExistingHypha)
- func FetchMycomarkupFile(h Hypha) (string, error)
- func FilterHyphaeWithText(src chan ExistingHypha) chan ExistingHypha
- func Index(path string)
- func Insert(h ExistingHypha) (madeNewRecord bool)
- func IsValidName(hyphaName string) bool
- func PathographicSort(src chan string) <-chan string
- func RenameHyphaTo(h ExistingHypha, newName string, replaceName func(string) string)
- func ResetCount()
- func WriteToMycoFile(h ExistingHypha, data []byte) error
- func YieldExistingHyphae() chan ExistingHypha
- type EmptyHypha
- type ExistingHypha
- type Hypha
- type MediaHypha
- type TextualHypha
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreFreeNames ¶
AreFreeNames checks if all given `hyphaNames` are not taken. If they are not taken, `ok` is true. If not, `firstFailure` is the name of the first met hypha that is not free.
func Count ¶
func Count() int
Count how many hyphae there are. This is a O(1), the number of hyphae is stored in memory.
func DeleteHypha ¶ added in v1.8.2
func DeleteHypha(h ExistingHypha)
DeleteHypha deletes the hypha from the storage.
func FetchMycomarkupFile ¶ added in v1.11.0
FetchMycomarkupFile tries to read text file of the given hypha. If there is no file, empty string is returned.
TODO: Get rid of this function.
func FilterHyphaeWithText ¶ added in v1.8.0
func FilterHyphaeWithText(src chan ExistingHypha) chan ExistingHypha
FilterHyphaeWithText filters the source channel and yields only those hyphae than have text parts.
func Index ¶
func Index(path string)
Index finds all hypha files in the full `path` and saves them to the hypha storage.
func Insert ¶ added in v1.8.2
func Insert(h ExistingHypha) (madeNewRecord bool)
Insert inserts the hypha into the storage, possibly overwriting the previous hypha with the same name. Count incrementation is done if needed. You cannot insert an empty hypha.
func IsValidName ¶ added in v1.6.0
IsValidName checks for invalid characters and path traversals.
func PathographicSort ¶ added in v1.5.0
PathographicSort sorts paths inside the source channel, preserving the path tree structure
func RenameHyphaTo ¶ added in v1.8.2
func RenameHyphaTo(h ExistingHypha, newName string, replaceName func(string) string)
RenameHyphaTo renames a hypha and renames stored filepaths as needed. The actual files are not moved, move them yourself.
func ResetCount ¶
func ResetCount()
ResetCount sets the value of hyphae count to zero. Use when reloading hyphae.
func WriteToMycoFile ¶ added in v1.9.0
func WriteToMycoFile(h ExistingHypha, data []byte) error
func YieldExistingHyphae ¶
func YieldExistingHyphae() chan ExistingHypha
YieldExistingHyphae iterates over all hyphae and yields all existing ones.
Types ¶
type EmptyHypha ¶
EmptyHypha is a hypha that does not exist and is not stored anywhere. You get one when querying for a hypha that was not created before.
func (*EmptyHypha) CanonicalName ¶ added in v1.8.2
func (e *EmptyHypha) CanonicalName() string
type ExistingHypha ¶ added in v1.8.2
ExistingHypha is not EmptyHypha. *MediaHypha and *TextualHypha implement this interface.
func Subhyphae ¶ added in v1.8.2
func Subhyphae(h Hypha) []ExistingHypha
Subhyphae returns slice of subhyphae.
type Hypha ¶
type Hypha interface { sync.Locker // CanonicalName returns the canonical name of the hypha. // // util.CanonicalName(h.CanonicalName()) == h.CanonicalName() CanonicalName() string }
Hypha is the hypha you know and love.
type MediaHypha ¶ added in v1.8.2
func ExtendEmptyToMedia ¶ added in v1.8.2
func ExtendEmptyToMedia(e *EmptyHypha, mediaFilePath string) *MediaHypha
ExtendEmptyToMedia returns a new media hypha with the same name as the given empty hypha. The created hypha is not stored yet.
func ExtendTextualToMedia ¶ added in v1.8.2
func ExtendTextualToMedia(t *TextualHypha, mediaFilePath string) *MediaHypha
ExtendTextualToMedia returns a new media hypha with the same name and text file as the given textual hypha. The new hypha is not stored yet.
func (*MediaHypha) CanonicalName ¶ added in v1.8.2
func (m *MediaHypha) CanonicalName() string
func (*MediaHypha) HasTextFile ¶ added in v1.8.2
func (m *MediaHypha) HasTextFile() bool
func (*MediaHypha) MediaFilePath ¶ added in v1.8.2
func (m *MediaHypha) MediaFilePath() string
func (*MediaHypha) SetMediaFilePath ¶ added in v1.8.2
func (m *MediaHypha) SetMediaFilePath(newPath string)
func (*MediaHypha) TextFilePath ¶ added in v1.8.2
func (m *MediaHypha) TextFilePath() string
type TextualHypha ¶ added in v1.8.2
TextualHypha is a hypha with text, and nothing else. An article, a note, a poem, whatnot.
func ExtendEmptyToTextual ¶ added in v1.8.2
func ExtendEmptyToTextual(e *EmptyHypha, mycoFilePath string) *TextualHypha
ExtendEmptyToTextual returns a new textual hypha with the same name as the given empty hypha. The created hypha is not stored yet.
func ShrinkMediaToTextual ¶ added in v1.8.2
func ShrinkMediaToTextual(m *MediaHypha) *TextualHypha
func (*TextualHypha) CanonicalName ¶ added in v1.8.2
func (t *TextualHypha) CanonicalName() string
func (*TextualHypha) HasTextFile ¶ added in v1.8.2
func (t *TextualHypha) HasTextFile() bool
func (*TextualHypha) TextFilePath ¶ added in v1.8.2
func (t *TextualHypha) TextFilePath() string